Question bank › Dynamic Programming
Dsa Dynamic Programming Warm-up

Split Array for Max Sum

Given an array of n integers, you need to determine the maximum sum that can be achieved by splitting the array into k non-empty continuous subarrays. Each subarray should have at least one element, and the split must maximize the sum of maximums of those subarrays. Input Format: - The first line contains an integer n (1 ≤ n ≤ 100), the number of elements in the array. - The second line contains n space-separated integers representing the array. - The third line contains an integer k (1 ≤ k ≤ n), the number of subarrays to split into. Output Format: - Print a single integer: the maximum sum of the maximums from the k subarrays. Example: Input: 4 1 2 3 4 2 Output: 7

Key concepts

dynamic_programmingsubarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.