Maze Path Finder

Backtracking Maze Path Finding

Problem Description

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).

Requirements:

  • Implement a function that takes the maze (2D list/array) as input and returns a list/array of strings where each string represents a valid path using the letters U, D, L, and R.
  • You cannot visit the same cell more than once in the same path.
  • If the starting cell or the destination cell is blocked, return an empty list.

Example:

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.

Bonus:

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!