一、leetcode地址
https://leetcode.com/problems/climbing-stairs/
二、问题描述
三、代码实现
语言:Python3
代码:
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1:
return 1
elif n == 2:
return 2
fi0 = 1;fi1 = 2;i = 2
while i < n:
temp = fi1
fi1 += fi0
fi0 = temp
i += 1
return fi1