方法1:本质上就是求斐波那契数列第number项的值:
def jumpFloor(number):
# write code here
x1,x2=1,2
if number<1:return 0
if number==1:return 1
if number==2:return 2
x=3
while x<=number:
temp=x1+x2
x1=x2
x2=temp
x+=1
return x2
#方法2:DFS,超时
def jump(currFloor):
if currFloor<1:return 0
if currFloor==1:return 1
if currFloor==2:return 2
return jump(currFloor-1)+jump(currFloor-2)