1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-21 21:16:45 +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>给你一个整数数组&nbsp;<code>arr</code> 和一个整数&nbsp;<code>d</code> 。每一步你可以从下标&nbsp;<code>i</code>&nbsp;跳到:</p>\n\n<ul>\n\t<li><code>i + x</code>&nbsp;,其中&nbsp;<code>i + x &lt; arr.length</code>&nbsp;且&nbsp;<code>0 &lt; x &lt;= d</code>&nbsp;。</li>\n\t<li><code>i - x</code>&nbsp;,其中&nbsp;<code>i - x &gt;= 0</code>&nbsp;且&nbsp;<code>0 &lt; x &lt;= d</code>&nbsp;。</li>\n</ul>\n\n<p>除此以外,你从下标&nbsp;<code>i</code> 跳到下标 <code>j</code>&nbsp;需要满足:<code>arr[i] &gt; arr[j]</code>&nbsp;且 <code>arr[i] &gt; arr[k]</code>&nbsp;,其中下标&nbsp;<code>k</code>&nbsp;是所有 <code>i</code>&nbsp;到 <code>j</code>&nbsp;之间的数字(更正式的,<code>min(i, j) &lt; k &lt; max(i, j)</code>)。</p>\n\n<p>你可以选择数组的任意下标开始跳跃。请你返回你 <strong>最多</strong>&nbsp;可以访问多少个下标。</p>\n\n<p>请注意,任何时刻你都不能跳到数组的外面。</p>\n\n<p>&nbsp;</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 --&gt; 8 --&gt; 6 --&gt; 7 。\n注意如果你从下标 6 开始,你只能跳到下标 7 处。你不能跳到下标 5 处因为 13 &gt; 9 。你也不能跳到下标 4 处,因为下标 5 在下标 4 和 6 之间且 13 &gt; 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>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= arr.length &lt;= 1000</code></li>\n\t<li><code>1 &lt;= arr[i] &lt;= 10^5</code></li>\n\t<li><code>1 &lt;= d &lt;= 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."