From 7b6223f7d911cf4be160b60e5405efad8e07028c Mon Sep 17 00:00:00 2001 From: LiangDazhu <42199191+LiangDazhu@users.noreply.github.com> Date: Fri, 11 Jun 2021 00:33:03 +0800 Subject: [PATCH] =?UTF-8?q?Update=200070.=E7=88=AC=E6=A5=BC=E6=A2=AF?= =?UTF-8?q?=E5=AE=8C=E5=85=A8=E8=83=8C=E5=8C=85=E7=89=88=E6=9C=AC.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added python version code --- problems/0070.爬楼梯完全背包版本.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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