Given a set of items, each with a weight and a value, determine the optimal subset to select such that the total weight does not exceed a specified limit and the total value is maximized. Note: There may be multiple optimal subsets.
Explanation: The optimal subset is [(4, 120)] since its total value is maximized without exceeding the weight limit.
Explanation: One of the optimal subsets is [(3, 40), (1, 10)] since its total value is maximized without exceeding the weight limit. Another optimal subset is [(2, 50)].
Subset selection with weight constraint
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak