Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Nearest Exit from Entrance in Maze (medium)
On this page

Problem Statement

You are given a maze of size m x n as a 2D grid with walls and open spaces. The walls are marked as '+', and the open spaces are marked as '.'. You also have an entrance point of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column of the cell you are initially standing at.

You can start the movement from the entrance, and in a single step, you can move up, down, left, or right into another open space. You can't move to the cell having a wall or outside of the maze.

Find the shortest path from the entrance to any exit

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page