Approach Summary
BFS from the start index, enqueuing i + arr[i] and i - arr[i] when in bounds. Return true if any index with arr[i] = 0 is reached.
How to Recognize This Pattern
- "Can you reach an index with value 0?"
- BFS on index states — mark visited to avoid cycles
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(n)
Tags
Array DFS BFS