diff --git a/problems/0070.爬楼梯完全背包版本.md b/problems/0070.爬楼梯完全背包版本.md index 69750f8f..2896ca88 100644 --- a/problems/0070.爬楼梯完全背包版本.md +++ b/problems/0070.爬楼梯完全背包版本.md @@ -147,6 +147,23 @@ class Solution { 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: