FastPrepSplit Array Largest Sum
Problems/Split Array Largest Sum

Split Array Largest Sum

Salesforce logoSalesforce● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Given an integer array nums of size n and an integer k, split nums into k non-empty contiguous subarrays such that the sum of maximum values of each subarray is minimized.

Function

splitArray(nums: int[], k: int) → int

Complete the function splitArray in the editor.

splitArray has the following parameters:

  1. 1. int[] nums: an integer array
  2. 2. int k: the number of subarrays to split into

Returns int: the minimum sum of the maximum values of the k subarrays

Examples

Example 1

nums = [1, 2, 3, 4, 5]k = 2return = 6

The optimal split is [1], [2, 3, 4, 5]. The sum of the maximum values of each subarray is max([1]) + max([2, 3, 4, 5]) = 1 + 5 = 6.

Constraints

  • 0 <= k <= 300
  • 0 <= n <= 300
  • 0 <= nums[i] <= 10^5

More Salesforce interview questions

  • Count Increasing TripletsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Reverse a Sublist of a Linked ListONSITE INTERVIEW · Seen Nov 2026
  • Rotting OrangesONSITE INTERVIEW · Seen Nov 2026
  • 3Sum SmallerONSITE INTERVIEW · Seen Nov 2026
  • Count Zero Request ServersONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays With Product Equal to KOA · Seen Nov 2026
  • Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
  • Get Message StatusOA · Seen Nov 2026
  • Group Identical Tree LevelsONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions
  • Maximum Points by Deleting ElementsIBM · OAIBM interview questions

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public int splitArray(int[] nums, int k) {
      // write your code here
    }

}
Checking account…