Update 0070.爬楼梯完全背包版本.md

添加 pyhthon3 版本代码
This commit is contained in:
haofeng
2021-06-09 23:13:21 +08:00
parent e470235464
commit 49b82575b4

View File

@ -147,6 +147,23 @@ class Solution {
Python Python
```python3
class Solution:
def climbStairs(self, n: int) -> int:
dp = [0]*(n + 1)
dp[0] = 1
m = 2
# 遍历背包
for j in range(n + 1):
# 遍历物品
for step in range(1, m + 1):
if j >= step:
dp[j] += dp[j - step]
return dp[n]
```
Go Go