Code RoomMinimum ship capacity
MediumPrep Room Coding #147

Minimum ship capacity

CodingAlgorithms & data structuresMid–Senior~30 min

Packages with given integer weights must be shipped in their given order within at most 'days' days. Each day you load consecutive packages onto a ship without exceeding its capacity. Return the minimum ship capacity that lets you ship everything within 'days' days. Assume 1 <= days <= len(weights).

Implement
min_ship_capacity(weights: list[int], days: int) → int
Examples
in[[1,2,3,4,5,6,7,8,9,10],5]out15
What 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 30 min
InputExpectedGot
[[1,2,3,4,5,6,7,8,9,10],5]15not run yetsample