Problem Statement
You are given an array sweetness
where each element represents the sweetness of a piece of chocolate. You want to divide the chocolate into k + 1
contiguous subarrays such that the minimum sweetness of the subarray with the least sweetness is maximized.
Return the maximum possible minimum sweetness of the subarray with the least sweetness.
Examples
Example 1:
Input: sweetness = [1, 2, 3, 4, 5, 6, 7, 8, 9], k = 5
Output: 6
Explanation: We divide the chocolate into k + 1 = 6 parts, such that the subarrays are
[1, 2], [3], [4], [5], [6], [7, 8, 9]
The minimum sweetnes among these subarrays is 6, and this is the maximum possible.