AlgoViz
← All drills
🧠 Drill · Think it through

Fewest moves through the maze

The problem

You're dropped into a grid maze with walls and open cells. From any cell you may step to an up/down/left/right neighbor, and every step costs the same. Return the minimum number of steps to reach the exit from the start, or report that it's unreachable. Each move has equal cost, and you want the shortest path measured in number of moves.

Don't jump to code. Walk the four questions an expert asks first — you'll build the habit, not just the answer.

1

Restate it

Before anything else — did you read what's actually being asked? Strip the story to the bare goal.

Strip away the story. What are we actually asked to return?