Hi,
I am getting TLE at test case 6. I have added documentation to improve readability.
Things I have tried:
- Check for infinite loops : Not possible since I am keeping track of every node visited.
- Check time complexity : It is O(n), which should be enough for 2 second limit.
- Replace cin and cout with scanf and printf : Didn't work.
Thanks