Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Split Array Largest Sum

Medium Acceptance 59% Points 30

Given an array of non-negative integers nums and an integer k, split the array into k non-empty contiguous subarrays. Return the minimum possible value of the largest sum among these subarrays.

Examples
Example 1

Example 1

Input: nums = [7,2,5,10,8], k = 2

Output: 18

Explanation: The best split is [7,2,5] and [10,8]. The largest sum among the subarrays is 18, which is minimized.

Example 2

Example 2

Input: nums = [1,2,3,4,5], k = 2

Output: 9

Explanation: The best split is [1,2,3] and [4,5]. The largest sum is 9, which is the minimum possible.

Example 3

Example 3

Input: nums = [1,4,4], k = 3

Output: 4

Explanation: Each element is its own subarray: [1], [4], [4]. The largest sum is 4.

Constraints
  • 1 = nums.length = 105
  • 0 = nums[i] = 105
  • 1 = k = nums.length
Topics
Binary Search
Companies
Apple
Added 19 Jul 2026 59% acceptance
Ln 1, Col 1Sign in to save your code
7 2 5 10 8
2
18