Packages must ship in the given order within days days. Each day one truck loads consecutive packages as long as total weight ≤ capacity. Return the minimum capacity that ships everything on time.
Signature
minCapacity(weights: int[], days: int) → intExample 1
weights = [1,2,3,4,5,6,7,8,9,10]
days = 5
output = 15
capacity 15: [1..5][6,7][8][9][10]
Example 2
weights = [3,2,2,4,1,4]
days = 3
output = 6
capacity 6
Constraints
1 ≤ days ≤ n ≤ 5·10^41 ≤ weights[i] ≤ 500
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).