This function is getting tle and wrong ans, only 3 cases passed

bool floydCycleRemoval(Node head)
{
if(head==NULL){
return false;
}
Node
s = head;
Nodef = head;
while(f!=NULL && f->next!=NULL){
s = s->next;
f = f->next->next;
}
if(s!=f){
return false;
}
s = head;
while(s->next!=f->next) {
s = s->next;
f = f->next;
}
f->next = NULL;
return true;
/
Code here */
}

Hey @kishoretaru, one thing you can check initially is if there’s one single node in linked list, so modify first if condition as

if(head==NULL or head->next==NULL)
return false;
you can also check out this code for your reference.