github我的刷题 https://github.com/chaor/LeetCode_Python_Accepted | 我翻译的python3.4官网教程 kitt.me/py3
动态规划或递归。
class Solution: # @param n, an integer # @return an integer def climbStairs(self, n): dp = [0, 1, 2] i = 3 while i <= n: dp.append(dp[i-1] + dp[i-2]) i += 1 return dp[n]