1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-26 07:18:56 +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>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,该数组的大小为 <code>n</code> ,请你计算 <code>nums[j] - nums[i]</code> 能求得的 <strong>最大差值 </strong>,其中 <code>0 &lt;= i &lt; j &lt; n</code> 且 <code>nums[i] &lt; nums[j]</code> 。</p>\n\n<p>返回 <strong>最大差值</strong> 。如果不存在满足要求的 <code>i</code> 和 <code>j</code> ,返回 <code>-1</code> 。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><strong>输入:</strong>nums = [7,<em><strong>1</strong></em>,<em><strong>5</strong></em>,4]\n<strong>输出:</strong>4\n<strong>解释:</strong>\n最大差值出现在 i = 1 且 j = 2 时nums[j] - nums[i] = 5 - 1 = 4 。\n注意尽管 i = 1 且 j = 0 时 nums[j] - nums[i] = 7 - 1 = 6 &gt; 4 ,但 i &gt; j 不满足题面要求,所以 6 不是有效的答案。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><strong>输入:</strong>nums = [9,4,3,2]\n<strong>输出:</strong>-1\n<strong>解释:</strong>\n不存在同时满足 i &lt; j 和 nums[i] &lt; nums[j] 这两个条件的 i, j 组合。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><strong>输入:</strong>nums = [<em><strong>1</strong></em>,5,2,<em><strong>10</strong></em>]\n<strong>输出:</strong>9\n<strong>解释:</strong>\n最大差值出现在 i = 0 且 j = 3 时nums[j] - nums[i] = 10 - 1 = 9 。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == nums.length</code></li>\n\t<li><code>2 &lt;= n &lt;= 1000</code></li>\n\t<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 80,
"likes": 81,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -137,7 +137,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"39.2K\", \"totalSubmission\": \"65.1K\", \"totalAcceptedRaw\": 39234, \"totalSubmissionRaw\": 65068, \"acRate\": \"60.3%\"}",
"stats": "{\"totalAccepted\": \"39.6K\", \"totalSubmission\": \"65.8K\", \"totalAcceptedRaw\": 39640, \"totalSubmissionRaw\": 65766, \"acRate\": \"60.3%\"}",
"hints": [
"Could you keep track of the minimum element visited while traversing?",
"We have a potential candidate for the answer if the prefix min is lesser than nums[i]."