We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4984050 + 854b74e commit 40a8e31Copy full SHA for 40a8e31
1 file changed
Python/unbounded_knapsack_problem.py
@@ -0,0 +1,9 @@
1
+def getMaximumValue(weights, values, n, maxWeight):
2
+ dp = [0] * (maxWeight + 1)
3
+
4
+ for w in range(1, maxWeight + 1):
5
+ for i in range(n):
6
+ if weights[i] <= w:
7
+ dp[w] = max(dp[w], dp[w - weights[i]] + values[i])
8
9
+ return dp[maxWeight]
0 commit comments