All Ancestors of a Node in a DAG
Medium
Topological Sort & DAG
For every node of a directed acyclic graph print all of its ancestors (nodes that can reach it), in ascending order, one node per line. Print an empty line for a node with no ancestors.
Constraints
1 <= n <= 1000 0 <= m <= 2000
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.