mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-26 07:18:56 +08:00
update
This commit is contained in:
@@ -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 <= i < j < n</code> 且 <code>nums[i] < nums[j]</code> 。</p>\n\n<p>返回 <strong>最大差值</strong> 。如果不存在满足要求的 <code>i</code> 和 <code>j</code> ,返回 <code>-1</code> 。</p>\n\n<p> </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 > 4 ,但 i > 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 < j 和 nums[i] < 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> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == nums.length</code></li>\n\t<li><code>2 <= n <= 1000</code></li>\n\t<li><code>1 <= nums[i] <= 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]."
|
||||
|
||||
Reference in New Issue
Block a user