Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Split Array Largest Sum

XPChallenge Points: 30
levelLevel: Hard

You are given an array of integers nums and a number k.
Your task is to divide the array into k continuous subarrays.
After dividing, each subarray will have a sum.
We want to minimize the maximum of these subarray sums.

Return the smallest possible value of this maximum.

A subarray must be contiguous, and every element must belong to exactly one subarray.

Example 1:

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

Output: 12

Explanation:

Possible split: [5,4,3] and [8,2] Subarray sums: 12 and 10 → Max is 12. No other split results in a smaller maximum.

Example 2:

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

Output: 2

Explanation:

Split: [1,1], [1,1], [1,1] Each subarray sum = 2 → Maximum = 2.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result