Given a 7x9 grid representing space and a list of asteroid coordinates, find all unique paths from the top-left corner to the bottom-right corner without hitting an asteroid. Movement is restricted to either down or right at any point.
Explanation: Step-by-step: with input [[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]], we start at the top-left corner and move right until we hit the asteroid at [0,1]. We then backtrack and move down until we reach the bottom-right corner, giving output 1.
Explanation: Step-by-step: with input [[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,1,0]], we start at the top-left corner and move right until we hit the asteroid at [0,1]. We then backtrack and move down until we reach the bottom-right corner, but we hit the asteroid at [6,8] which blocks the path, giving output 0.
Master coding challenges related to Backtracking and solve the [Backup] Avoiding Asteroids in Space Travel problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak