Capacity To Ship Packages Within D Days Problem
Capacity To Ship Packages Within D Days Problem — ExecCode Medium DSA Practice
Solve the Capacity To Ship Packages Within D Days problem on ExecCode. Free online medium DSA practice in Binary Search. Write and run code in Java, C++, Python — no signup required to run.
Problem description
A conveyor belt has packages that must be shipped from one port to another within days days. The i-th package on the conveyor belt has weight weights[i]. Each day we load the ship with packages on the conveyor belt in the given order, and we may not load more weight than the maximum weight capacity of the ship. Return the least weight capacity of the ship that results in all the packages being shipped within days days.
Examples
Input weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], days = 5; Output 15. Input weights = [3, 2, 2, 4, 1, 4], days = 3; Output 6. Input weights = [1, 2, 3, 1, 1], days = 4; Output 3
Constraints
1 ≤ days ≤ weights.length ≤ 5×10⁴ 1 ≤ weights[i] ≤ 500
Practice Capacity To Ship Packages Within D Days free on ExecCode. Browse DSA problems, topic map, and placement guides.