Maximum Units on a Truck
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are loading boxes onto a truck. box_types[i] = [count_i, units_i] says there are count_i boxes of type i, and each of them holds units_i units.
The truck can carry at most truck_size boxes in total. You may pick any boxes you like (partial boxes are not allowed, but you can take any number of boxes of a type up to its count).
Return the maximum total number of units the truck can carry.
Examples
Constraints
- 1 <= box_types.length <= 1000
- 1 <= count_i, units_i <= 1000
- 1 <= truck_size <= 10^6
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.