1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-24 22:38:57 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个整数数组 <code>nums</code> 。<code>nums</code> 中,子数组的 <strong>范围</strong> 是子数组中最大元素和最小元素的差值。</p>\n\n<p>返回 <code>nums</code> 中 <strong>所有</strong> 子数组范围的 <strong>和</strong> <em>。</em></p>\n\n<p>子数组是数组中一个连续 <strong>非空</strong> 的元素序列。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,2,3]\n<strong>输出:</strong>4\n<strong>解释:</strong>nums 的 6 个子数组如下所示:\n[1],范围 = 最大 - 最小 = 1 - 1 = 0 \n[2],范围 = 2 - 2 = 0\n[3],范围 = 3 - 3 = 0\n[1,2],范围 = 2 - 1 = 1\n[2,3],范围 = 3 - 2 = 1\n[1,2,3],范围 = 3 - 1 = 2\n所有范围的和是 0 + 0 + 0 + 1 + 1 + 2 = 4</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,3,3]\n<strong>输出:</strong>4\n<strong>解释:</strong>nums 的 6 个子数组如下所示:\n[1],范围 = 最大 - 最小 = 1 - 1 = 0\n[3],范围 = 3 - 3 = 0\n[3],范围 = 3 - 3 = 0\n[1,3],范围 = 3 - 1 = 2\n[3,3],范围 = 3 - 3 = 0\n[1,3,3],范围 = 3 - 1 = 2\n所有范围的和是 0 + 0 + 0 + 2 + 0 + 2 = 4\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [4,-2,-3,4,1]\n<strong>输出:</strong>59\n<strong>解释:</strong>nums 中所有子数组范围的和是 59\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 1000</code></li>\n\t<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>进阶:</strong>你可以设计一种时间复杂度为 <code>O(n)</code> 的解决方案吗?</p>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 181,
"likes": 187,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"35.1K\", \"totalSubmission\": \"55.9K\", \"totalAcceptedRaw\": 35095, \"totalSubmissionRaw\": 55927, \"acRate\": \"62.8%\"}",
"stats": "{\"totalAccepted\": \"35.6K\", \"totalSubmission\": \"56.7K\", \"totalAcceptedRaw\": 35575, \"totalSubmissionRaw\": 56735, \"acRate\": \"62.7%\"}",
"hints": [
"Can you get the max/min of a certain subarray by using the max/min of a smaller subarray within it?",
"Notice that the max of the subarray from index i to j is equal to max of (max of the subarray from index i to j-1) and nums[j]."