Code Room
CodingMediumcod-g1451
Subject GreedyLevel Entry–Mid~13 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.