https://leetcode.com/problems/linked-list-cycle-ii/

我的code

class Solution(object):
    def detectCycle(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        if not head : return None
        slow, fast = head, head

        while fast and fast.next:
            slow = slow.next
            fast = fast.next.next
            if slow == fast:
                break
        if fast == None or fast.next == None: return None

        slow = head
        while slow != fast:
            slow = slow.next
            fast = fast.next

        return slow