Cycle detection and removal in Linkedlist

In the line 24 of the code above i have used the condition
while( fast!=NULL and fast->next!=NULL) , i am all getting all test cases correct but if i change this condition to
while( fast->next !=NULL and fast !=NULL) , i dont get all test cases correct.

Why this is happening as both the ways mean the same ?

both are different conditions actually

if fast is null then fast->next will give you runtime error

but if you use this condition fast!=NULL and fast->next!=NULL
then first fast is checked if first condition false then compiler didn’t check second because what will be second answer will be false
because false && true = false
false&& false = false;

i hope you got the point

Thanks sir , got the point.

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.