mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个整数数组 <code>arr</code> 和一个整数 <code>d</code> 。每一步你可以从下标 <code>i</code> 跳到:</p>\n\n<ul>\n\t<li><code>i + x</code> ,其中 <code>i + x < arr.length</code> 且 <code>0 < x <= d</code> 。</li>\n\t<li><code>i - x</code> ,其中 <code>i - x >= 0</code> 且 <code>0 < x <= d</code> 。</li>\n</ul>\n\n<p>除此以外,你从下标 <code>i</code> 跳到下标 <code>j</code> 需要满足:<code>arr[i] > arr[j]</code> 且 <code>arr[i] > arr[k]</code> ,其中下标 <code>k</code> 是所有 <code>i</code> 到 <code>j</code> 之间的数字(更正式的,<code>min(i, j) < k < max(i, j)</code>)。</p>\n\n<p>你可以选择数组的任意下标开始跳跃。请你返回你 <strong>最多</strong> 可以访问多少个下标。</p>\n\n<p>请注意,任何时刻你都不能跳到数组的外面。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/02/meta-chart.jpeg\" style=\"height: 419px; width: 633px;\"></p>\n\n<pre><strong>输入:</strong>arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2\n<strong>输出:</strong>4\n<strong>解释:</strong>你可以从下标 10 出发,然后如上图依次经过 10 --> 8 --> 6 --> 7 。\n注意,如果你从下标 6 开始,你只能跳到下标 7 处。你不能跳到下标 5 处因为 13 > 9 。你也不能跳到下标 4 处,因为下标 5 在下标 4 和 6 之间且 13 > 9 。\n类似的,你不能从下标 3 处跳到下标 2 或者下标 1 处。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><strong>输入:</strong>arr = [3,3,3,3,3], d = 3\n<strong>输出:</strong>1\n<strong>解释:</strong>你可以从任意下标处开始且你永远无法跳到任何其他坐标。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><strong>输入:</strong>arr = [7,6,5,4,3,2,1], d = 1\n<strong>输出:</strong>7\n<strong>解释:</strong>从下标 0 处开始,你可以按照数值从大到小,访问所有的下标。\n</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<pre><strong>输入:</strong>arr = [7,1,7,1,7,1], d = 2\n<strong>输出:</strong>2\n</pre>\n\n<p><strong>示例 5:</strong></p>\n\n<pre><strong>输入:</strong>arr = [66], d = 1\n<strong>输出:</strong>1\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= arr.length <= 1000</code></li>\n\t<li><code>1 <= arr[i] <= 10^5</code></li>\n\t<li><code>1 <= d <= arr.length</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 83,
|
||||
"likes": 85,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"5.1K\", \"totalSubmission\": \"8.8K\", \"totalAcceptedRaw\": 5081, \"totalSubmissionRaw\": 8763, \"acRate\": \"58.0%\"}",
|
||||
"stats": "{\"totalAccepted\": \"5.3K\", \"totalSubmission\": \"9.1K\", \"totalAcceptedRaw\": 5280, \"totalSubmissionRaw\": 9078, \"acRate\": \"58.2%\"}",
|
||||
"hints": [
|
||||
"Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]).",
|
||||
"dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i."
|
||||
|
Reference in New Issue
Block a user