Maximum Units on a Truck
EasyGreedy
Decode it first. Clues, constraints, pattern and plan before any code.box_types[i] = [count, units] means there are count boxes of type i, and each holds units units. The truck carries at most truck_size boxes, of any types. Return the maximum total units you can load.
box_types = [[1, 3], [2, 2], [3, 1]], truck_size = 4 → 8 (3 + 2 + 2 + 1)
box_types = [[5, 10], [2, 5], [4, 7], [3, 9]], truck_size = 10 → 91Constraints
1 <= box_types.length <= 10001 <= count, units <= 10001 <= truck_size <= 10^6