https://ide.codingblocks.com/s/309122 (Line: 267)
The code is very simple. Still it doesnot work
this condition is not correct
while (fast->next != NULL && fast != NULL) {
fast = fast->next->next; // fast moves 2 steps
slow = slow->next; // slow moves 1 step
}
first you have to check fast then fast->next
if fast is null then you are checking fast->next which is actually giving run error
correct one
while (fast != NULL && fast->next != NULL) {
fast = fast->next->next; // fast moves 2 steps
slow = slow->next; // slow moves 1 step
}
I don;t understand. What is ->?
what are you talking?
i don’t understand