/*
struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) :
        val(x), next(NULL) {
    }
};
*/
#include <unordered_set>
class Solution {
public:
    ListNode* EntryNodeOfLoop(ListNode* pHead) {
        unordered_set<ListNode*> ans;
        while(pHead!=nullptr){
            if(ans.count(pHead)){
                return pHead;
            }
            ans.insert(pHead);
            pHead=pHead->next;
        }
        return nullptr;
    }
};