79. 0/1 Knapsack
MediumDynamic programming
Given item weights, item values and a bag capacity, return the maximum total value you can carry. Each item can be taken at most once.
Example 1
Input: weights = [1, 3, 4, 5], values = [1, 4, 5, 7], capacity = 7 Output: 9 Explanation: items of weight 3 and 4
Constraints
1 ≤ items ≤ 1000 ≤ capacity ≤ 1000