Prototype: implement prototype(List<Item> items, int capacity) returning long with a direct baseline.
Final: implement solve(List<Item> items, int capacity) with the mechanism and bounds described above. Each item has weight > 0 and value >= 0; capacity must be >= 0, otherwise IllegalArgumentException. Return the maximum total value with each item used at most once. Empty selection and unused capacity are allowed. Both stages have the same observable contract. The prototype may use the simpler method; final must use the target data structure.
The supplied nested record types define the API. All methods are static members of Exercise.
Complete the starter code, then run the checks.
Results and errors will appear here.
Java runs on this device with CheerpJ 4.3.