Amazon | OA | find out the sum of min(subarray) * sum(subarray)
Anonymous User
298

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

Comments (1)