mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 14:58:56 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给定一个整数数组 <code>A</code>,你可以从某一起始索引出发,跳跃一定次数。在你跳跃的过程中,第 1、3、5... 次跳跃称为奇数跳跃,而第 2、4、6... 次跳跃称为偶数跳跃。</p>\n\n<p>你可以按以下方式从索引 <code>i</code> 向后跳转到索引 <code>j</code>(其中 <code>i < j</code>):</p>\n\n<ul>\n\t<li>在进行奇数跳跃时(如,第 1,3,5... 次跳跃),你将会跳到索引 <code>j</code>,使得 <code>A[i] <= A[j]</code>,<code>A[j]</code> 是可能的最小值。如果存在多个这样的索引 <code>j</code>,你只能跳到满足要求的<strong>最小</strong>索引 <code>j</code> 上。</li>\n\t<li>在进行偶数跳跃时(如,第 2,4,6... 次跳跃),你将会跳到索引 <code>j</code>,使得 <code>A[i] >= A[j]</code>,<code>A[j]</code> 是可能的最大值。如果存在多个这样的索引 <code>j</code>,你只能跳到满足要求的<strong>最小</strong>索引 <code>j</code> 上。</li>\n\t<li>(对于某些索引 <code>i</code>,可能无法进行合乎要求的跳跃。)</li>\n</ul>\n\n<p>如果从某一索引开始跳跃一定次数(可能是 0 次或多次),就可以到达数组的末尾(索引 <code>A.length - 1</code>),那么该索引就会被认为是好的起始索引。</p>\n\n<p>返回好的起始索引的数量。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><strong>输入:</strong>[10,13,12,14,15]\n<strong>输出:</strong>2\n<strong>解释: </strong>\n从起始索引 i = 0 出发,我们可以跳到 i = 2,(因为 A[2] 是 A[1],A[2],A[3],A[4] 中大于或等于 A[0] 的最小值),然后我们就无法继续跳下去了。\n从起始索引 i = 1 和 i = 2 出发,我们可以跳到 i = 3,然后我们就无法继续跳下去了。\n从起始索引 i = 3 出发,我们可以跳到 i = 4,到达数组末尾。\n从起始索引 i = 4 出发,我们已经到达数组末尾。\n总之,我们可以从 2 个不同的起始索引(i = 3, i = 4)出发,通过一定数量的跳跃到达数组末尾。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><strong>输入:</strong>[2,3,1,1,4]\n<strong>输出:</strong>3\n<strong>解释:</strong>\n从起始索引 i=0 出发,我们依次可以跳到 i = 1,i = 2,i = 3:\n\n在我们的第一次跳跃(奇数)中,我们先跳到 i = 1,因为 A[1] 是(A[1],A[2],A[3],A[4])中大于或等于 A[0] 的最小值。\n\n在我们的第二次跳跃(偶数)中,我们从 i = 1 跳到 i = 2,因为 A[2] 是(A[2],A[3],A[4])中小于或等于 A[1] 的最大值。A[3] 也是最大的值,但 2 是一个较小的索引,所以我们只能跳到 i = 2,而不能跳到 i = 3。\n\n在我们的第三次跳跃(奇数)中,我们从 i = 2 跳到 i = 3,因为 A[3] 是(A[3],A[4])中大于或等于 A[2] 的最小值。\n\n我们不能从 i = 3 跳到 i = 4,所以起始索引 i = 0 不是好的起始索引。\n\n类似地,我们可以推断:\n从起始索引 i = 1 出发, 我们跳到 i = 4,这样我们就到达数组末尾。\n从起始索引 i = 2 出发, 我们跳到 i = 3,然后我们就不能再跳了。\n从起始索引 i = 3 出发, 我们跳到 i = 4,这样我们就到达数组末尾。\n从起始索引 i = 4 出发,我们已经到达数组末尾。\n总之,我们可以从 3 个不同的起始索引(i = 1, i = 3, i = 4)出发,通过一定数量的跳跃到达数组末尾。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><strong>输入:</strong>[5,1,3,4,2]\n<strong>输出:</strong>3\n<strong>解释: </strong>\n我们可以从起始索引 1,2,4 出发到达数组末尾。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ol>\n\t<li><code>1 <= A.length <= 20000</code></li>\n\t<li><code>0 <= A[i] < 100000</code></li>\n</ol>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 136,
|
||||
"likes": 140,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"3.7K\", \"totalSubmission\": \"8.2K\", \"totalAcceptedRaw\": 3723, \"totalSubmissionRaw\": 8194, \"acRate\": \"45.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"3.9K\", \"totalSubmission\": \"8.4K\", \"totalAcceptedRaw\": 3851, \"totalSubmissionRaw\": 8444, \"acRate\": \"45.6%\"}",
|
||||
"hints": [],
|
||||
"solution": {
|
||||
"id": "117",
|
||||
|
||||
Reference in New Issue
Block a user