https://leetcode.com/problems/sum-of-subarray-minimums/
Very like this one.
Give an integer array
Describe A * B as below:
A is a subarray's minimum element
B is the sum of the subarray
Try to find out sum of every subarray's A * B
example:
array [1,3,2]
subarray
[1]
[3]
[2]
[1,3]
[3,2]
[1,3,2]
result = 1 * 1 + 2 * 2 + 3 * 3 + 1 * 4 + 2 * 5 + 1 * 6 = 32