Skip to content

Latest commit

 

History

History
77 lines (30 loc) · 1.08 KB

File metadata and controls

77 lines (30 loc) · 1.08 KB

Description

Given an array of integers A, find the sum of min(B), where B ranges over every (contiguous) subarray of A.

Since the answer may be large, return the answer modulo 10^9 + 7.

 

Example 1:

Input: [3,1,2,4]

Output: 17

Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4]. 

Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.  Sum is 17.

 

Note:

    <li><code>1 &lt;= A.length &lt;= 30000</code></li>
    
    <li><code>1 &lt;= A[i] &lt;= 30000</code></li>
    

 

Solutions

Python3

Java

...