Jump Game III
Given an array of non-negative integers arr, you are initially positioned at index start of the array. When you are at index i, you can jump to either i + arr[i] or i - arr[i].
Return whether you can reach any index whose value is 0.
Notice that you cannot jump outside of the array at any time.
Example 1
Input
arr = [4,2,3,0,3,1,2], start = 5Output
trueStarting from index 5, you can reach index 3 with value 0 via paths such as 5 -> 4 -> 1 -> 3 or 5 -> 6 -> 4 -> 1 -> 3.
Example 2
Input
arr = [4,2,3,0,3,1,2], start = 0Output
trueStarting from index 0, one possible way to reach index 3 with value 0 is 0 -> 4 -> 1 -> 3.
Constraints
- 1 <= arr.length <= 5 * 10^4
- 0 <= arr[i] < arr.length
- 0 <= start < arr.length