# 4ms c solution based in pointers-meeting idea

• `````` typedef  struct ListNode ListNode;
``````

``````ListNode* pslow ,*pfast;

while( pslow&&pfast){
pslow = pslow->next;
if(pfast->next){
pfast = pfast->next;
pfast = pfast->next;
}else {
pfast = pfast->next;
break;
}

if(pfast == pslow)break;

}
if(  !pslow||!pfast)return false;
return true;
``````

}

The main idea is that a slow pointer moving one step while a fast pointer moving two steps from a same start point, but they will meet at the same positon if there is any cycle.

• that's a wrong idea.
if the cycle has even nodes and the distance of fastnode and the slownode when slow one gets into cycle is even, these two pointers will never meet each other!!!

• I don't think so. The fast pointer move two steps and the slow one move one. Each time they move their distance decreases by one. No matter the distance is even or odd, it will decreases one by one till zero. Then they will meet. This is a proved method. No need to argue on that.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.