标签:code logs linked tno link return div des highlight
https://leetcode.com/problems/linked-list-cycle-ii/#/description
public ListNode detectCycle(ListNode head) {
      
        if (head == null) {
            return null;
        }
        ListNode fast = head;
        ListNode slow = head;
        do {
            if (fast == null || fast.next == null) {
                return null;
            }
            fast = fast.next.next;
            slow = slow.next;
        } while (fast != slow);
        fast = head;
        while (fast != slow) {
            fast = fast.next;
            slow = slow.next;
        }
        return fast;
    }
标签:code logs linked tno link return div des highlight
原文地址:http://www.cnblogs.com/apanda009/p/7123253.html