diff --git a/problems/0070.爬楼梯完全背包版本.md b/problems/0070.爬楼梯完全背包版本.md index 9fc33bb8..90c9a8c0 100644 --- a/problems/0070.爬楼梯完全背包版本.md +++ b/problems/0070.爬楼梯完全背包版本.md @@ -146,7 +146,18 @@ class Solution { ``` Python: - +```python +class Solution: + def climbStairs(self, n: int) -> int: + m = 2 + dp = [0] * (n + 1) + dp[0] = 1 + for i in range(n + 1): + for j in range(1, m + 1): + if i >= j: + dp[i] += dp[i - j] + return dp[-1] +``` Go: ```go