Sum of Subarray Minimums

Given an array of integers, find the sum of the minimums of every contiguous subarray of the array. Return the sum modulo 1,000,000,007.

Constraints

  • 1 <= arr.length <= 3 * 10^4
  • 1 <= arr[i] <= 3 * 10^4
Saving… · 2 lines
class Solution:
def sum_of_subarray_minimums(self, arr: List[int]) -> int:
Console

Click Run to execute sample tests.