Class Solution
- java.lang.Object
-
- g0901_1000.s0907_sum_of_subarray_minimums.Solution
-
public class Solution extends Object
907 - Sum of Subarray Minimums.Medium
Given an array of integers arr, find the sum of
min(b), wherebranges over every (contiguous) subarray ofarr. Since the answer may be large, return the answer modulo109 + 7.Example 1:
Input: arr = [3,1,2,4]
Output: 17
Explanation:
Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].
Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. Sum is 17.
Example 2:
Input: arr = [11,81,94,43,3]
Output: 444
Constraints:
1 <= arr.length <= 3 * 1041 <= arr[i] <= 3 * 104
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intsumSubarrayMins(int[] arr)
-