Test case 5, 6 Fail


Please Check.

consider the case when entire LL is circular
for ex
LL is like 1,2,3 and 3 ka next is 1
entire LL is in loop
then your code fails
you have to handle the case separately when fast->next==head


Updated but still failing test cases.

Your mistake
if( head->next == NULL || head == NULL){
return false;
}
correct one
if( head == NULL || head->next == NULL){
return false;
}

first check head is null or not only then head->next
because if head==NULL then
head->next means NULL->next which will give run time error

Modified Code

Passing all testcases

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.