โ† Amazon questions

Maze exit

Filed under Amazon

Free read 1 of 3

Confirm allowed directions (4-directional vs 8-directional) and obstacle representation.

The question

Find the minimum number of moves to exit an M*N maze containing obstacles (bombs), starting from (0,0) and moving to (M-1, N-1).

Constraints

  • 1 <= M, N <= 100
  • Cells contain passable paths, walls, or bombs.

Examples

Input
maze = [[0,0],[0,0]], start=(0,0), end=(1,1)
Output
2
Why
Takes 2 steps from top-left to bottom-right.

Approach

  1. Confirm allowed directions (4-directional vs 8-directional) and obstacle representation.

Tips

  • What they are testing: Test cases with no possible path, blocked start/end, and multiple alternative paths.
  • Common mistake: Using DFS instead of BFS to find the shortest path in an unweighted grid.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.