238. Split Array Largest Sum

HardBinary Search

Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split. A subarray is a contiguous part of the array.

Examples

Input: [7,2,5,10,8] 2

Output: 18

Explanation: Split into [7,2,5] and [10,8]; the larger sum 18 is minimized.

Constraints

  • 1 <= nums.length <= 1000
  • 0 <= nums[i] <= 10^6
  • 1 <= k <= min(50, nums.length)
Loading...

Run checks all cases above. Submit evaluates all test cases.