解答:
class Solution:
def detectCycle(self, head):
if head is None or head.next is None or head.next.next is None:
return None
fast = head
slow = head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
fast = head
while fast != slow:
slow = slow.next
fast = fast.next
return fast