AICS interview question

Sum of Subarray Minimums (Medium)