Ezvor

1059. All Paths from Source Lead to Destination

MediumGraph Theory Preparing judge… LeetCode
Graph TheoryTopological SortKosaraju's AlgorithmTarjan's SCC Algorithm

Hints

Hint 1
What if we can reach to a cycle from the source node?
Hint 2
Then the answer will be false, because we eventually get trapped in the cycle forever.
Hint 3
What if the we can't reach to a cycle from the source node? Then we need to ensure that from all visited nodes from source the unique node with indegree = 0 is the destination node.