I tried to solve this problem. But getting WA . I have used DFS to solve. Please help. I don’t know where i am going wrong .

My Solution - http://ideone.com/OVPROd

1 Like

I know it is pretty late and i couldn’t be able to solve this question either.
But i think that you have assumed it as a directed graph. where as per question it is undirected.

1 Like