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 环形链表)
猜你喜欢
转载自blog.csdn.net/qq_45657288/article/details/108983275
今日推荐
周排行