Split Array Largest Sum
Given an integer array nums and an integer k, split nums into k non-empty contiguous subarrays so that the largest sum among those subarrays is as small as possible, and return that minimized largest sum.
Open official problem prompt ↗Choose split points so the heaviest resulting subarray is as light as possible, and report that weight.
Loading trucks that drive a fixed route in order: you fix a weight limit, load boxes onto a truck until the next box would exceed it, then start a new truck. The tightest limit that still fits everything into k trucks is the answer.
- Input
- nums = [7,2,5,10,8], k = 2
- Output
- 18
- Why
- Splitting into [7,2,5] (sum 14) and [10,8] (sum 18) gives a maximum of 18, the smallest achievable.
1 <= nums.length <= 10000 <= nums[i] <= 10^61 <= k <= min(50, nums.length)