#1926 - Nearest Exit from Entrance in Maze
Given an m × n matrix maze with empty cells '.' and walls '+', and an entrance position [row, col], return the number of steps in the shortest path from the entrance to the nearest exit. An exit is any empty cell on the border of the maze (not the entrance itself). Return -1 if no path exists.
| Input | Output |
|---|---|
maze = [["+","+",".","+"],[".",".",".","+"],["+","+","+","."]], entrance = [1,2] | 1 |
maze = [["+","+","+"],[".",".","."],["+","+","+"]], entrance = [1,0] | 2 |
maze = [[".","+"] | -1 |