Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack.
Each item can only be selected once (hence 0/1 - either take it or leave it).
You are given two integer arrays:
Return the maximum value that can be achieved.
Recurrence Relation:
This is the fundamental bounded knapsack problem and a cornerstone of DP.
weights = [1,2,3], values = [6,10,12], W = 522weights = [1,1,1], values = [10,20,30], W = 250weights = [5], values = [10], W = 401 <= n <= 1001 <= weights[i], values[i] <= 10001 <= W <= 1000Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers