what am i doing wrong in this
Circular linked list
@mikkyimran
there is error in your find cycle code ,I have made changes to your function here is code
bool cycle(node head){
node slow =head;
node* fast =head;
while(fast!=NULL && fast->next!=NULL){
fast= fast->next->next;
slow= slow->next;
if (slow == fast)
break;
}
if (slow == fast) {
node * start = head;
node * loop = slow;
while (start->next != loop->next) {
start = start->next;
loop = loop->next;
}
loop->next = NULL;
return true;
} else {
return false;
}
}
Hope you get it
sir i think i am doing the same thing in my code. can please comment out the error in the ide so that i can understand better.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.