Sum of Subarray Minimums Solution With JavaScript O(n) Complexity
Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 10<sup>9</sup> + 7.
Problem Statement
Given an array:
arr = [3, 1, 2, 4]
We want:...