Problem: Maze Distance
public static int distanceToExit(char[][] maze) {
// your implementation goes here
}
For example:
S . .
# # .
. . E
There is only one path, and it has 4 moves:
(0, 0) -> (0, 1) -> (0, 2) -> (1, 2) -> (2, 2)
So the method returns 4.
For this maze:
S . #
# . #
. # E
The exit cannot be reached, so the method returns -1.
Like the previous problem, this one can be solved with any of the maze search algorithms we have seen. However, the question asks for the queue-based search.