Given an integer array nums, choose any non-empty subarray. Let the min-product of that subarray be the minimum element multiplied by the sum of the subarray. Return the maximum min-product among all subarrays, modulo 1,000,000,007. Example: Input: nums = [1,2,3,2] Output: 14 Explanation: The best subarray is [2,3,2], whose minimum is 2 and sum is 7, giving 14. Pattern focus: Range Contribution with monotonic stacks and prefix sums.
nums = positive integer array
maximum min-product of any subarray, modulo 1,000,000,007
Example 1:
Input:
nums = [1,2,3,2]
Output:
14
Explanation:
The subarray [2,3,2] maximizes minimum times sum.
Example 2:
Input:
nums = [2,3,3,1,2]
Output:
18
Explanation:
A subarray with a larger sum and a good minimum can be optimal.