Interview Questions/Coding/Split Array Largest Sum

Split Array Largest Sum

Preview mode. Log in to edit, run, submit, and save progress.

Hard

Split Array Largest Sum

Given an integer array nums and an integer k, split nums into k non-empty contiguous parts. The score of a split is the largest sum among all parts. Return the minimum possible score.

Examples

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 part sum is 18.

Approach hint

Try checking if a maximum allowed part sum is possible.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp