What is wrong in this code

Nodeslow =head;
Node
fast = head;
while( head!= NULL&&head->next != NULL){
fast = fast->next->next;
slow = slow->next;
if( fast == slow){
slow = head;
if(slow == fast) {
while(fast->next != slow) {
fast = fast->next;
}
}
else{
while( slow->next != fast->next){
slow = slow ->next;
fast = fast->next;
}
}
fast->next = NULL;

       return true;
   }

}
return false;
}

it should be fast instead of head

there are some corner cases you have not handle
like if complete list is a cycle, or if head is null or if only 1 element exists

you can check this code

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.