Dsa
Backtracking
Easy
Escape the Maze
You are given a maze represented as a 2D grid of '0's (free cell) and '1's (blocked cell). Your goal is to find one path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1). You can move in four directions: up, down, left, or right. If there is no path, return 'No Path'. The input consists of two integers n and m followed by n lines of m integers (0 or 1). Example:
Input:
3 3
0 1 0
0 0 0
0 1 0
Output:
[(0, 0), (1, 0), (2, 0), (2, 1), (2, 2)]
Key concepts
backtrackingmazepathfinding
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