0/1 knapsack

Write codeMedium25 min

Your task

You have a knapsack of integer capacity. Each item is given as [weight, value] and can be taken at most once. Return the maximum total value of a subset whose total weight does not exceed the capacity. Capacity is non-negative; the item list may be empty.

Examples

knapsack_01(capacity: int, items: list[list[int]]) -> int
Example 1
Inputknapsack_01(10, [[5, 10], [4, 40], [6, 30], [3, 50]])
Output90