0/1 Knapsack
00:00
AmazonMicrosoftTCS
Given n items with weights and values, and capacity W, find max value fitting in knapsack. Each item used at most once.
Examples
Input → w=[1,3,4,5], v=[1,4,5,7], W=7
Output → 9
Note: items 2+3: 3+4=7, value=9
Input → w=[1,2,3], v=[6,10,12], W=5
Output → 22
Note: items 2+3
Input → w=[5], v=[10], W=3
Output → 0