bool hasCycle(struct ListNode *head)
{
struct ListNode *fast=head,*slow=head;
while((fast)!=NULL && (fast->next)!=NULL)
{
fast=fast->next->next;
slow=slow->next;
if(fast==slow)
{
return true;
}
}
return false;
}
[Leetcode] (141 circular linked list)
Guess you like
Origin blog.csdn.net/qq_45657288/article/details/108983275
Recommended
Ranking