Given an integer array nums and an integer k, split nums into
k non-empty contiguous subarrays such that the largest sum of any subarray
is minimized. Return the minimized largest sum of the split.
nums = [7,2,5,10,8], k = 218nums = [1,2,3,4,5], k = 29nums = [1,4,4], k = 34The feasibility function is monotone: if we can split nums into ≤ k subarrays with max sum ≤ M, then we can certainly do the same with max sum ≤ M+1. This monotone property lets us binary search for the minimum M that is still feasible. S = sum(nums) is the size of the search space.
Greedy check: Scan left→right, accumulate current sum. When the next element would push us over mid, start a new partition. Count partitions needed.