Problem Link: https://codeforces.com/contest/510/problem/B
Submission Link: https://codeforces.com/contest/510/submission/83349621
I am trying to detect a cycle by using dfs and trying not to print Yes if we have come back to the last visited node in our dfs search… I can’t understand where I am going wrong. It’s failing some tests. Please help.