class Solution:
"""
@param n: An integer
@return: An integer
"""
def climbStairs(self, n):
# write your code here
if n == 0: return 1
if n == 1: return 1
tmpList = [1,1]
for i in range(0,n-1):
x = tmpList[-1] + tmpList[-2]
tmpList.append(x)
return tmpList[-1]
...
n.如果起始跳n階的話,剩余的n-2階就有 f(n-n) 種跳法;
class Solution:
"""
@param n: An integer
@return: An integer
"""
def climbStairs(self, n):
# write your code here
if n == 0: return 1
return 2**(n-1)