class Solution {
public:
ListNode *detectCycle(ListNode *head) {
unordered_sethashset;
while(head){
if(hashset.count(head)){
return head;
}
hashset.insert(head);
head=head->next;
}
return NULL;
}
};



