Find Eventual Safe Nodes
Medium
Functional Graphs & Cycles
A node is safe if every path from it ends at a terminal node (no outgoing edges) rather than entering a cycle. Print all safe nodes in increasing order. Nodes are 0-indexed; each line lists the out-neighbours of a node.
Constraints
1 <= n <= 10^4
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.