[LeetCode] 907. Sum of Subarray Minimums 子数组最小值之和



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:

  1. 1 <= A.length <= 30000
  2. 1 <= A[i] <= 30000



Github 同步地址:

https://github.com/grandyang/leetcode/issues/907



类似题目:



参考资料:

https://leetcode.com/problems/sum-of-subarray-minimums/



LeetCode All in One 题目讲解汇总(持续更新中...)

猜你喜欢

转载自www.cnblogs.com/grandyang/p/11273330.html
今日推荐