Capacity To Ship Packages Within D Days
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
Packages sit on a conveyor belt in a fixed order; weights[i] is the weight of the i-th package. Each day you load packages onto a ship **in belt order**, stopping before the total would exceed the ship's capacity. Packages cannot be reordered or split.
Return the smallest integer ship capacity that lets you ship every package within days days.
The capacity must be at least the heaviest package. Aim for O(n log(sum(weights))).
Examples
Constraints
- 1 <= days <= weights.length <= 5 * 10^4
- 1 <= weights[i] <= 500
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.