mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update 0070.爬楼梯完全背包版本.md
Added python version code
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user