mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-12-14 14:42:36 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个数组 <code>nums</code> ,它包含 <code>n</code> 个正整数。你需要计算所有非空连续子数组的和,并将它们按升序排序,得到一个新的包含 <code>n * (n + 1) / 2</code> 个数字的数组。</p>\n\n<p>请你返回在新数组中下标为<em> </em><code>left</code> 到 <code>right</code> <strong>(下标从 1 开始)</strong>的所有数字和(包括左右端点)。由于答案可能很大,请你将它对 10^9 + 7 取模后返回。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,2,3,4], n = 4, left = 1, right = 5\n<strong>输出:</strong>13 \n<strong>解释:</strong>所有的子数组和为 1, 3, 6, 10, 2, 5, 9, 3, 7, 4 。将它们升序排序后,我们得到新的数组 [1, 2, 3, 3, 4, 5, 6, 7, 9, 10] 。下标从 le = 1 到 ri = 5 的和为 1 + 2 + 3 + 3 + 4 = 13 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,2,3,4], n = 4, left = 3, right = 4\n<strong>输出:</strong>6\n<strong>解释:</strong>给定数组与示例 1 一样,所以新数组为 [1, 2, 3, 3, 4, 5, 6, 7, 9, 10] 。下标从 le = 3 到 ri = 4 的和为 3 + 3 = 6 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,2,3,4], n = 4, left = 1, right = 10\n<strong>输出:</strong>50\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 10^3</code></li>\n\t<li><code>nums.length == n</code></li>\n\t<li><code>1 <= nums[i] <= 100</code></li>\n\t<li><code>1 <= left <= right <= n * (n + 1) / 2</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 35,
|
||||
"likes": 40,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"7K\", \"totalSubmission\": \"12.6K\", \"totalAcceptedRaw\": 6974, \"totalSubmissionRaw\": 12639, \"acRate\": \"55.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7.3K\", \"totalSubmission\": \"13.2K\", \"totalAcceptedRaw\": 7296, \"totalSubmissionRaw\": 13155, \"acRate\": \"55.5%\"}",
|
||||
"hints": [
|
||||
"Compute all sums and save it in array.",
|
||||
"Then just go from LEFT to RIGHT index and calculate answer modulo 1e9 + 7."
|
||||
|
||||
Reference in New Issue
Block a user