Problem: Maze Path
public static List<Position> pathToExit(char[][] maze) {
// your implementation goes here
}
Notice we return a List<Position>. In the chapter, the Position class was made private. Assume we made it public so we can return a list of positions.
For example:
S . .
# # .
. . E
There is only one path, and it is:
(0, 0) -> (0, 1) -> (0, 2) -> (1, 2) -> (2, 2)
For this maze:
S . #
# . #
. # E
The exit cannot be reached, so the method returns an empty list.