Sponsored
Use these hints if you're stuck. Try solving on your own first.
Treat the graph as undirected. Start a dfs from the root, if you come across an edge in the forward direction, you need to reverse the edge.
Solve with full IDE support and test cases