Maze Path Finder

Backtracking Maze Algorithms

Maze Path Finder

Given a 2D maze represented by a matrix, where 1 represents an open cell and 0 represents an obstacle, write a function to find all possible paths from the top-left cell (start) to the bottom-right cell (finish). You can move in four directions: up (U), down (D), left (L), and right (R).

Requirements:

  • The maze is given as an M x N matrix of integers (0s and 1s).
  • Start at position (0, 0) and end at position (M-1, N-1).
  • Only move to cells with the value 1 (open cells). Moving to a cell with 0 is not allowed.
  • You cannot visit a cell more than once in a single path.
  • Return an array (or list) of strings, where each string represents a path using the characters U, D, L, and R.

Notes:

  • On November 30, we remember history and reflect on past challenges. Use your coding skills to navigate through the labyrinth of obstacles just as pioneers navigated uncharted paths!
  • The order in which paths are returned does not matter.

Example:

For the maze:

1 0 0
1 1 0
0 1 1

One valid path (if it exists) could be: DDRDR which corresponds to Down, Down, Right, Down, Right.

Get started by implementing a function that performs backtracking to explore all valid paths.