Code RoomMaximum items in van
MediumPrep Room Coding #651

Maximum items in van

CodingAlgorithms & data structuresEntry–Mid~13 min

A parcel van has room for at most capacity boxes. boxes[i] = [count, units] says the depot holds count identical boxes of type i, each containing units items. You may load any whole boxes you like, mixing types, as long as the number of boxes loaded stays within capacity. Return the maximum total number of items the van can carry. Example: boxes [[1,3],[2,2],[3,1]] with capacity 4 carries 8 items.

Implement
max_loaded_items(boxes: list[list[int]], capacity: int) → int
Examples
in[[[1,3],[2,2],[3,1]],4]out8
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 13 min
InputExpectedGot
[[[1,3],[2,2],[3,1]],4]8not run yetsample