Skip to content

Update 背包理论基础01背包-1.md #768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions problems/背包理论基础01背包-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down