mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part1
This commit is contained in:
43
算法题(国内版)/problem (Chinese)/跳跃游戏 III [jump-game-iii].html
Normal file
43
算法题(国内版)/problem (Chinese)/跳跃游戏 III [jump-game-iii].html
Normal file
@@ -0,0 +1,43 @@
|
||||
<p>这里有一个非负整数数组 <code>arr</code>,你最开始位于该数组的起始下标 <code>start</code> 处。当你位于下标 <code>i</code> 处时,你可以跳到 <code>i + arr[i]</code> 或者 <code>i - arr[i]</code>。</p>
|
||||
|
||||
<p>请你判断自己是否能够跳到对应元素值为 0 的 <strong>任一</strong> 下标处。</p>
|
||||
|
||||
<p>注意,不管是什么情况下,你都无法跳到数组之外。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>arr = [4,2,3,0,3,1,2], start = 5
|
||||
<strong>输出:</strong>true
|
||||
<strong>解释:</strong>
|
||||
到达值为 0 的下标 3 有以下可能方案:
|
||||
下标 5 -> 下标 4 -> 下标 1 -> 下标 3
|
||||
下标 5 -> 下标 6 -> 下标 4 -> 下标 1 -> 下标 3
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>arr = [4,2,3,0,3,1,2], start = 0
|
||||
<strong>输出:</strong>true
|
||||
<strong>解释:
|
||||
</strong>到达值为 0 的下标 3 有以下可能方案:
|
||||
下标 0 -> 下标 4 -> 下标 1 -> 下标 3
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>arr = [3,0,2,1,2], start = 2
|
||||
<strong>输出:</strong>false
|
||||
<strong>解释:</strong>无法到达值为 0 的下标 1 处。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= arr.length <= 5 * 10^4</code></li>
|
||||
<li><code>0 <= arr[i] < arr.length</code></li>
|
||||
<li><code>0 <= start < arr.length</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user