class Solution {
public:
ListNode* EntryNodeOfLoop(ListNode* pHead)
{
unordered_map<ListNode*, bool> nodemap;
while(pHead){
if(nodemap.find(pHead) != nodemap.end()) return pHead;
else{
nodemap[pHead] = true;
}
pHead = pHead->next;
}
return nullptr;
}
}; 


京公网安备 11010502036488号