class Solution:
def EntryNodeOfLoop(self, pHead):
# write code here
if pHead is None or pHead.next is None:
return None
fast = pHead
slow = pHead
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
fast = pHead
while fast != slow:
fast = fast.next
slow = slow.next
return fast
网友评论