Loading
Loading
A warehouse has a queue of pallets, each with a handling time, that must be split among a number of workers. Each worker takes one contiguous run of the queue — at least one pallet, in queue order — and the shift ends when the busiest worker finishes.
Split loads into exactly workers non-empty contiguous parts so that the largest part total is as small as possible, and return that total.
loads = [4, 9, 3, 6, 2, 8], workers = 3cap 13?[4, 9] [3, 6, 2] [8] — three workers sufficecap 12?[4] [9, 3] [6, 2] [8] — needs fouranswer 13the smallest cap that three workers can meet13Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n log(sum)) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
[4, 9] | [3, 6, 2] | [8] has largest shift 13, and no split does better.
Example 2
One block per worker: each carries 5.