collections/knapsack_utils library

0/1 Knapsack solver with reconstruction — roadmap #444.

Classes

KnapsackUtils
Item with weight and value.

Functions

knapsack01(List<KnapsackUtils> items, int capacity) → (int, List<int>)
Solves the 0/1 knapsack: (max value, indices of chosen items). items and capacity must be non-negative.