public boolean isLoop(Node head){
Node slow = head;
Node fast = head;
while(fast!=null && fast.next!=null)
{
slow = slow.next;
fast = fast.next.next;
if(slow==fast)
return true;
}
return false;
}
判断链表是否循环链表
最新推荐文章于 2024-05-01 15:40:16 发布