Solved this in N^2 time complexity but got TLE. Does anyone have a better solution????
Question explained: Assume you have an array of integers [2, 3, 2, 1]. Return the sum of all subarrays multiplied with the minimum element in the subarray, e.g.
sum = 2 * 2 + (2+3) * 2 + (2+3+2) * 2 + (2+3+2+1) * 1 + 3 * 3 + (3+2) * 2 + (3+2+1) * 1 + 2 * 2 + (2 + 1) * 1 + 1 * 1 = 69