class Solution:
def climbStairs(self, n: int) -> int:
if n <= 2:
return n
pre, cur = 1, 2
for i in range(3,n+1):
pre, cur = cur, pre + cur
return cur
刷题记录:70. 爬楼梯
最新推荐文章于 2024-11-12 10:59:16 发布