题目:70. 爬楼梯
我的感悟:
- 居然自己先写出来了!!继续努力!!
理解难点:
听课笔记:
我的代码:
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1:
return 1
dp = [0] *(n+1)
dp[1] = 1
dp[2] = 2
for i in range(3,n+1):
dp[i] = dp[i-1]+dp[i-2]
return dp[n]