You are given a maze represented by a 2D grid where each cell is either passable or an obstacle. A cell with a value of 0
is passable, and a cell with a value of 1
is blocked. Your task is to find all valid paths from the top-left corner (start) to the bottom-right corner (destination) using backtracking. The allowed moves are Up (U
), Down (D
), Left (L
), and Right (R
).
U
, D
, L
, and R
.For the maze:
[[0, 0, 0],
[0, 1, 0],
[0, 0, 0]]
A possible valid path could be: DDRURD
(Down, Down, Right, Up, Right, Down). Your solution should return all such valid paths.
Since today, February 23, is known as Defender of the Fatherland Day in some regions, imagine that each valid path represents a hero's journey through a maze of challenges. Share your solution and inspire others with your heroic algorithm!