Smallest truck that meets the deadline
Packages leave a warehouse in a fixed order; weights[i] is the weight of package i. Each day one truck loads packages in order until the next one would exceed its capacity, then departs. Return the smallest integer capacity that ships every package within days days.
Constraints: at least one package, every weight ≥ 1, days ≥ 1. Aim for O(n log(sum(weights))) time.
Besides the tests, one large input (750 packages) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
min_capacity([1,2,3,4,5,6,7,8,9,10], 5)→15min_capacity([3,2,2,4,1,4], 3)→6min_capacity([1,2,3,1,1], 4)→3