Mark As Completed Discussion

To get the shortest path, we also check if it is possible to reach the destination node from the source node, as there is a possibility that it may not be reachable. The destination node is then added to the list of routes which gives us the shortest path.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment