判断链表是否有环-CSDN博客

网站介绍:文章浏览阅读33次。public static boolean hasCycle(ListNode head){ if(head==null||head.next==null) return false; ListNode slow=head; ListNode fast=head.next; while(slow!=fast) { if(fast==null||fast.next==null...