# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
class Solution:
    def EntryNodeOfLoop(self, pHead):
        # write code here
        dict = {}
        while pHead:
            if pHead.val not in dict:
                print(pHead.val)
                dict[pHead.val] = 1
                pHead = pHead.next
            else:
                return pHead
            

不管非环部分是不是为空如:{},{2},只是输入的时候人为的把环部分和非环部分分开了,在遍历的时候都是2还是第一个节点。