day10
/* https://leetcode-cn.com/problems/linked-list-cycle-lcci/ */ package 链表; public class _0208环路检测 { public ListNode detectCycle(ListNode head) { //利用快慢指针求解 if(head==null || head.next==null) return null; ListNode slow = head; ListNode fast = head.next; while(fast!=null && fast.next!=null){ if (slow==fast) break; slow = slow.next; fast = fast.next.next; } return null; } }