Depth-First Search
802. Find Eventual Safe States
In a directed graph, a node is safe if every path leaving it eventually reaches a terminal (no-outgoing-edges) node — i.e. it can never wander into a cycle. Return all safe nodes sorted. Safety is…
Loading…