The problem. A conveyor belt carries packages with weights, which must be shipped in order within days days. Each day the ship is loaded with the next packages on the belt, never more than its weight capacity. Return the smallest capacity that ships everything within days days.
weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], days = 5 -> 15
weights = [3, 2, 2, 4, 1, 4], days = 3 -> 6 ([3, 2], [2, 4], [1, 4])
weights = [1, 2, 3, 1, 1], days = 4 -> 3Members only · free account
The rest of this lesson, with 6 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson