Jump Game III — Rust Coding Problem
Difficulty: hard | Category: graph
Problem Description
Given an array of non-negative integers `arr`, you are initially positioned at `start` index of the array. When you are at index `i`, you can jump to `i + arr[i]` or `i - arr[i]`, check if you can reach any index with value 0. Notice that you can not jump outside of the array at any time. **Approach:** BFS or DFS from `start`, tracking visited indices.
Examples
Example 1
Input: arr = [4,2,3,0,3,1,2], start = 5
Output: true
Explanation: All paths from start reach an index with value 0.
Example 2
Input: arr = [4,2,3,0,3,1,2], start = 0
Output: true
Example 3
Input: arr = [3,0,2,1,2], start = 2
Output: false