LeetCode: https://leetcode.com/problems/split-array-largest-sum/
Given a non-empty array with n positive integers, arr, and a number k with 1 <= k <= n, the goal is to split arr into k non-empty subarrays so that the largest sum across all subarrays is minimized. Return the largest sum across all k subarrays after making it as small as possible. Each subarray must contain at least one value.
Example 1:
- Input:
arr = [10, 5, 8, 9, 11], k = 3 - Output:
17(Split:[10, 5], [8, 9], [11]. Sums: 15, 17, 11. Max: 17)
Example 2:
- Input:
arr = [10, 10, 10, 10, 10], k = 2 - Output:
30
10
0
5
1
8
2
9
3
11
4
k=3
Step 1 / 6
Step 1:
Range of possible answers: [max(arr), sum(arr)]. l=11, r=43.
Pointers: l=11, mid=27, r=43
Focus: default
k=3