Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
How many cycles can each node at most be part of?
Each node can be part of at most one cycle. Start from each node and find the cycle that it is part of if there is any. Save the already visited nodes to not repeat visiting the same cycle multiple times.