Trains the technique from
LeetCode 410Split Array Largest SumThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Parcels are queued along a loading bay in one fixed line, and their masses are the integer array weights. A fleet of trucks vehicles is waiting at the far end.
The crew works front to back and never reorders the queue, so each vehicle is handed one unbroken run of neighbouring parcels. Every parcel is loaded, no run overlaps another, and no vehicle may drive off empty. A vehicle's load is the total mass of the run it received.
The shift only ends when the most heavily laden vehicle has finished its route, so the crew wants the biggest of the trucks loads to come out as small as it possibly can. Report the mass of that heaviest load under the best possible cut.
Example 1
Cutting the line into 4 9 | 3 12 | 6 1 gives loads of 13, 15 and 7, and no other set of two cuts pushes the biggest load below 15.
Example 2
There are exactly as many vehicles as parcels, so each vehicle carries a single parcel and the heaviest load is the heaviest parcel.
Example 3
With one vehicle the whole queue travels together, so the answer is the total mass.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def min_heaviest_load(weights: list[int], trucks: int) -> int:public int minHeaviestLoad(int[] weights, int trucks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.