Skip to content

Commit 4088bf7

Browse files
Merge pull request youngyangyang04#768 from casnz1601/patch-2
Update 背包理论基础01背包-1.md
2 parents 2ecd4ac + 3f99399 commit 4088bf7

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

problems/背包理论基础01背包-1.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ Python:
315315
def test_2_wei_bag_problem1(bag_size, weight, value) -> int:
316316
rows, cols = len(weight), bag_size + 1
317317
dp = [[0 for _ in range(cols)] for _ in range(rows)]
318-
res = 0
319318

320319
# 初始化dp数组.
321320
for i in range(rows):
@@ -334,8 +333,6 @@ def test_2_wei_bag_problem1(bag_size, weight, value) -> int:
334333
else:
335334
# 定义dp数组: dp[i][j] 前i个物品里,放进容量为j的背包,价值总和最大是多少。
336335
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - cur_weight]+ cur_val)
337-
if dp[i][j] > res:
338-
res = dp[i][j]
339336

340337
print(dp)
341338

0 commit comments

Comments
 (0)