diff --git a/Python/unbounded_knapsack_problem.py b/Python/unbounded_knapsack_problem.py new file mode 100644 index 00000000..c45b4ed9 --- /dev/null +++ b/Python/unbounded_knapsack_problem.py @@ -0,0 +1,9 @@ +def getMaximumValue(weights, values, n, maxWeight): + dp = [0] * (maxWeight + 1) + + for w in range(1, maxWeight + 1): + for i in range(n): + if weights[i] <= w: + dp[w] = max(dp[w], dp[w - weights[i]] + values[i]) + + return dp[maxWeight] \ No newline at end of file