首页 > 编程语言 > 详细

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

时间:2019-07-30 23:38:28      阅读:143      评论:0      收藏:0      [点我收藏+]



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 题目讲解汇总(持续更新中...)

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

原文:https://www.cnblogs.com/grandyang/p/11273330.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!