Search
⌘K

Leetcode 1856. Maximum Subarray Min-Product

Find the maximum value of (minimum element of a contiguous subarray) × (sum of that subarray) over all non-empty subarrays and return it mod 1e9+7. Key insight: for each element treated as the subarray minimum, use a monotonic stack to find its maximal span and prefix sums to compute the sum efficiently (n up to 1e5).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.