#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param number int整型
# @return int整型
#
class Solution:
def jumpFloor(self , number: int) -> int:
# write code here
if number <=2:
return number
# dp = [0] * (number+1)
# dp[1] = 1
# dp[2] = 2
# for i in range(3,number+1):
# dp[i] = dp[i-1] + dp[i-2]
# return dp[number]
# 常数空间复杂度
a = 1
b = 2
c = 0
for i in range(3,number+1):
c = a + b
a,b = b,c # 值的交替迭代
return c