From 3f99399aa48319b7942de32fd6b7e66cbeb527df Mon Sep 17 00:00:00 2001 From: Asterisk <44215173+casnz1601@users.noreply.github.com> Date: Sun, 19 Sep 2021 18:34:00 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E8=83=8C=E5=8C=85=E7=90=86=E8=AE=BA?= =?UTF-8?q?=E5=9F=BA=E7=A1=8001=E8=83=8C=E5=8C=85-1.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 冗余python临时变量 --- ...272\345\237\272\347\241\20001\350\203\214\345\214\205-1.md" | 3 --- 1 file changed, 3 deletions(-) diff --git "a/problems/\350\203\214\345\214\205\347\220\206\350\256\272\345\237\272\347\241\20001\350\203\214\345\214\205-1.md" "b/problems/\350\203\214\345\214\205\347\220\206\350\256\272\345\237\272\347\241\20001\350\203\214\345\214\205-1.md" index 7d04b51493..32ad30d380 100644 --- "a/problems/\350\203\214\345\214\205\347\220\206\350\256\272\345\237\272\347\241\20001\350\203\214\345\214\205-1.md" +++ "b/problems/\350\203\214\345\214\205\347\220\206\350\256\272\345\237\272\347\241\20001\350\203\214\345\214\205-1.md" @@ -315,7 +315,6 @@ Python: def test_2_wei_bag_problem1(bag_size, weight, value) -> int: rows, cols = len(weight), bag_size + 1 dp = [[0 for _ in range(cols)] for _ in range(rows)] - res = 0 # 初始化dp数组. for i in range(rows): @@ -334,8 +333,6 @@ def test_2_wei_bag_problem1(bag_size, weight, value) -> int: else: # 定义dp数组: dp[i][j] 前i个物品里,放进容量为j的背包,价值总和最大是多少。 dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - cur_weight]+ cur_val) - if dp[i][j] > res: - res = dp[i][j] print(dp)