LC: 499. The Maze III
Solutions: Default Code:
//TODO
1506. Find Root of N-Ary Tree:The Essence: It is also a little bit different than the usual DFS problems as you cannot stop and change direction until you encounter a wall or the destination.
It is important to note that, you have to decide if DFS can pass over the next cell, not the current cell. For the case in the image; you must pass at the first encounter but you have to stop after another turn of DFS (and in a different direction.)

Details:
You can use the classical DFS method:
You can use the Dijkstra'S algorithm as well:
Last updated