Dsa
Backtracking
Easy
Maze Pathfinding
You are given a simple rectangular grid representing a maze, where '0' represents an open path and '1' represents a wall. Your task is to find all unique paths from the top-left corner to the bottom-right corner of the grid. You can only move right or down.
Input:
- The first line contains two integers R and C, the number of rows and columns (1 <= R, C <= 10).
- The next R lines contain C characters (either '0' or '1') representing the grid.
Output:
- Print all unique paths from the top-left to the bottom-right corner, one per line. Each path should be represented as a list of coordinate pairs: [(x1,y1), (x2,y2), ...] with 1-based indexing.
Example:
Input:
3 3
0 0 1
0 0 0
1 0 0
Output:
[(1,1), (1,2), (2,2), (3,2), (3,3)]
[(1,1), (1,2), (2,2), (2,3), (3,3)]
Key concepts
backtrackinggridrecursion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now