119. Sum of Subarray Minimums
Medium
Given an array numeros, consider all of its non-empty contiguous subarrays. Find the smallest value in each subarray and add those values together.
Return the sum modulo 1000000007. If the sum is negative, return its representative between 0 and 1000000006.
Example 1
Input: numeros = [3, 1, 2, 4]
Output: 17
Explanation: The subarray minimums add up to 17.
Example 2
Input: numeros = [2, 2]
Output: 6
Explanation: The four subarrays have minimums 2, 2, 2, and 2.
Example 3
Input: numeros = [-1, 3]
Output: 1
Explanation: The sum of the minimums is 1.
Constraints
- 1 <= numeros.length <= 100000
- -100000 <= numeros[i] <= 100000
StackArrays
Saved in this browser
Caso 1
numeros =
[3,1,2,4]
Expected =
17
Caso 2
numeros =
[2,2]
Expected =
6
Caso 3
numeros =
[-1,3]
Expected =
1
Run checks these 3 cases. Submit runs all 12, including hidden ones.