My code is not passing all the test cases,help needed.
Also please tell the problem in my approach.
Cycle detection and removal
Then please help me to do that
here u r assuming that both pointer will meet at start of circle . which is not always.
First detect there is cycle or not using simple two pointer.
now if no cycle present return false otherwise.
reinitialse slow pointer with head .
and move both pointer one step till slow->next=fast->next;
once the condition meet
fast->next=NULL
and return false
1 Like
Thanks sir it works fine