Problem
A maze is a grid where "+" is a wall and "." is open floor. You stand at entrance = [row, col] (an open cell) and can step up, down, left or right onto open floor. An exit is any open cell on the border of the maze, except the entrance itself. Return the fewest steps to reach an exit, or -1 if there is none you can reach.
Example 1
maze = [["+", "+", ".", "+"],
Example 2
[".", ".", ".", "+"],
Example 3
- Input
- ["+", "+", "+", "."]], entrance = [1, 2]
- Output
- 1
- Why
- step up to [0, 2]
Example 4
- Input
- maze = [[".", "+"]], entrance = [0, 0]
- Output
- -1
- Why
- the entrance does not count
Constraints
1 <= maze.length, maze[i].length <= 100maze[i][j] is "+" or "."entrance is an open cell inside the maze