a = a.next.next b=b.next if a==b: c=head while c!=b: c=c.next b=b.next return c returnNone
#题解 classSolution(object): defdetectCycle(self, head): fast, slow = head, head whileTrue: ifnot (fast and fast.next): return fast, slow = fast.next.next, slow.next if fast == slow: break fast = head while fast != slow: fast, slow = fast.next, slow.next return fast