java.lang.Object
g0901_1000.s0907_sum_of_subarray_minimums.Solution

public class Solution extends Object
907 - Sum of Subarray Minimums.<p>Medium</p> <p>Given an array of integers arr, find the sum of <code>min(b)</code>, where <code>b</code> ranges over every (contiguous) subarray of <code>arr</code>. Since the answer may be large, return the answer <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> arr = [3,1,2,4]</p> <p><strong>Output:</strong> 17</p> <p><strong>Explanation:</strong></p> <p>Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].</p> <p>Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. Sum is 17.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> arr = [11,81,94,43,3]</p> <p><strong>Output:</strong> 444</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= arr.length <= 3 * 10<sup>4</sup></code></li> <li><code>1 <= arr[i] <= 3 * 10<sup>4</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • sumSubarrayMins

      public int sumSubarrayMins(int[] arr)