class Solution:
def jumpFloor(self, number):
# write code here
def dfs(n):
res=0
if rec[n]!=-1:
return rec[n]
elif n==1:res= 1
elif n==2:res= 2
else:
res= dfs(n-1)+dfs(n-2)
rec[n]=res
return res
rec=[-1 for i in range(number+1)]
return dfs(number)
网友评论