You are given an array of integers nums and a number k.
Your task is to divide the array into k continuous subarrays.
After dividing, each subarray will have a sum.
We want to minimize the maximum of these subarray sums.
Return the smallest possible value of this maximum.
A subarray must be contiguous, and every element must belong to exactly one subarray.
Input: nums = [5, 4, 3, 8, 2], k = 2
Output: 12
Explanation:
Possible split: [5,4,3] and [8,2] Subarray sums: 12 and 10 → Max is 12. No other split results in a smaller maximum.
Input: nums = [1, 1, 1, 1, 1, 1], k = 3
Output: 2
Explanation:
Split: [1,1], [1,1], [1,1] Each subarray sum = 2 → Maximum = 2.
Accepted:
Submission: