Minimum conveyor capacity
You ship packages in order along a conveyor over D days. The i-th package has weight weights[i]. Each day you load packages onto the belt in the given order; the total loaded weight on a day cannot exceed the belt capacity. Return the least belt capacity that lets you ship every package within D days. Constraints: 1 <= len(weights) <= 5*10^4, 1 <= weights[i] <= 500, 1 <= D <= len(weights).
Implement
ship_within_days(weights: list[int], D: int) → intExamples
in
[[1,2,3,4,5,6,7,8,9,10],5]out15What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
[[1,2,3,4,5,6,7,8,9,10],5]15not run yetsample