1011. Capacity to Ship Packages Within D Days
Practice Capacity to Ship Packages Within D Days for free on NudgeCode: Medium, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Packages sit on a conveyor belt in a fixed order; weights[i] is the weight of package i. Each day a ship loads packages from the front of the belt, in order, as long as the total weight stays within the ship's capacity.
Return the smallest capacity that ships every package within days days.
Example
weights = [1,2,3,4,5,6,7,8,9,10], days = 5 -> 15
Constraints
- 1 <= days <= weights.length <= 5 * 10^4
- 1 <= weights[i] <= 500