Given an array of non-negative integers
arr
, you are initially positioned atstart
index of the array. When you are at indexi
, you can jump toi + arr[i]
ori - arr[i]
, check if you can reach to any index with value 0.
Notice that you can not jump outside of the array at any time.
給予一個非負整數的陣列
arr
,你最開始在陣列中索引值為start
的位置。當你在索引值i
時,你可以跳到i + arr[i]
或是i - arr[i]
,檢查你是否可以到達任何值為 0 的索引值。
注意你任何時候都不該跳出陣列之外。
start
0
的所有點LeetCode
C++