解答:
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)