Search
⌘K

Leetcode 1926. Nearest Exit from Entrance in Maze

Given a grid maze with walls ('+') and empty cells ('.'), find the minimum number of up/down/left/right moves from the given entrance to the nearest exit (an empty border cell, excluding the entrance). This is a shortest-path problem on a grid, typically solved with BFS to return the distance to the nearest exit or -1 if none is reachable.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late February, 2025

Meta

Senior

LC 1926

Comments

Your account is free and you can post anonymously if you choose.