Dsa
Graphs Bfs
Easy
Shortest Path in a Maze
Given a 2D grid representing a maze with '0's (open path) and '1's (walls), find the length of the shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1). You can move up, down, left, and right. If there is no path, return -1.
For example, given the input:
0 0 1 0
0 0 1 0
1 0 0 0
0 1 1 0
The output should be:
7
Key concepts
graphsbfsshortest path
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