Implement prototype(weights: list[int], days: int) -> int and solve with the same signature. Return the smallest integer capacity that partitions positive integer weights, in their given order, into at most days nonempty contiguous groups. Extra days need not be used. Empty weights return 0 for positive days.

Example: ([1, 2, 3, 4, 5], 3) returns 6.

Raise ValueError for days <= 0 or any nonpositive weight. Prototype: test capacities with the feasibility scan. Final: binary search the capacity bound, using O(1) auxiliary space. Preserve inputs, including on failure.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.