Skip to content

Commit 49b8257

Browse files
committed
Update 0070.爬楼梯完全背包版本.md
添加 pyhthon3 版本代码
1 parent e470235 commit 49b8257

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ class Solution {
147147

148148
Python:
149149

150+
```python3
151+
class Solution:
152+
def climbStairs(self, n: int) -> int:
153+
dp = [0]*(n + 1)
154+
dp[0] = 1
155+
m = 2
156+
# 遍历背包
157+
for j in range(n + 1):
158+
# 遍历物品
159+
for step in range(1, m + 1):
160+
if j >= step:
161+
dp[j] += dp[j - step]
162+
return dp[n]
163+
```
164+
165+
166+
150167

151168
Go:
152169

0 commit comments

Comments
 (0)