Please tell why I am getting TLE ?
Cycle Detection and Removal
You haven’t put any breaking condition to break out of the loop in the function.
Please check now. I am still getting wrong answer and also TLE for some testcases
@vaishnavtannu You have unnecessarily made your code lengthy.
Have a look at this code for cycle detection and removal.