Leetcode 907. Sum of Subarray Minimums
Compute the sum of the minimum element of every contiguous subarray of arr, returned modulo 10^9+7. Because n can be up to 3·10^4, the intended approach counts how many subarrays each element is the minimum (a monotonic-stack previous/next-smaller pattern) to achieve O(n) time.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.