/*
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};
*/
#include <vector>
class Solution {
public:
ListNode* EntryNodeOfLoop(ListNode* pHead) {
vector<ListNode*>v;
while(pHead)
{
for(auto a:v)
{
if(a==pHead)
{
return pHead;
}
}
v.push_back(pHead);
pHead=pHead->next;
}
return nullptr;
}
};



京公网安备 11010502036488号