Back to problems

Split Array into K Parts with Minimum Sum of Maxima

Algorithm · Salesforce · Hard

You are given an array nums and a positive integer k. Partition nums into exactly k non-empty contiguous subarrays that cover the array in its original order. For one partition, compute the largest element in each subarray, then add these k maxima together. The goal is to minimize that total. Implement splitArray so that it returns the minimum possible sum of subarray maxima. Example 1: Explanation: The split [3,1] and [4,1,5] has maxima 3 and 5, totaling 8, which is…

Checking your access…