From 49b82575b40e9beff1d19c6995962ac3465da3fc Mon Sep 17 00:00:00 2001 From: haofeng <852172305@qq.com> Date: Wed, 9 Jun 2021 23:13:21 +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=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20pyhthon3=20=E7=89=88=E6=9C=AC=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0070.爬楼梯完全背包版本.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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: