Santa Claus ๐ is testing a new sleigh simulator inside a maze in the workshop. The maze is represented as a matrix of characters.
Your task is to implement a function that determines if it is possible to reach the exit (E) starting from the initial position (S).
Maze rules:
S: Santa's initial position.E: Maze exit..: Free path.#: Wall (blocks the path).S and one E.canEscape([
['S', '.', '#', '.'],
['#', '.', '#', '.'],
['.', '.', '.', '.'],
['#', '#', '#', 'E']
])
// โ true
canEscape([
['S', '#', '#'],
['.', '#', '.'],
['.', '#', 'E']
])
// โ false
canEscape([
['S', 'E']
])
// โ true
canEscape([
['S', '.', '.', '.', '.'],
['#', '#', '#', '#', '.'],
['.', '.', '.', '.', '.'],
['.', '#', '#', '#', '#'],
['.', '.', '.', '.', 'E']
])
// โ true
canEscape([
['S', '.', '.'],
['.', '.', '.'],
['#', '#', '#'],
['.', '.', 'E']
])
// โ false
Things to keep in mind:
Tip: This problem can be solved in several ways, but search algorithms like BFS (Breadth-First Search) or DFS (Depth-First Search) are ideal for these types of challenges.

