LeetCode 1011, Medium. Topics: Array, Binary Search. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 18 parametrized pytest cases, and a playground notebook:
Problem
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 a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship.
Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within days days.
Examples
Constraints
- 1 <= days <= weights.length <= 5 * 10^4
- 1 <= weights[i] <= 500
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode 250, NeetCode All. Last modified on September 7, 2026