Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider how reversing each edge of the graph can help us.
How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?
Solve with full IDE support and test cases