We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
boolhas_cycle(SinglyLinkedListNode*head){unordered_set<SinglyLinkedListNode*>address;// a set of SLL num_set// for every node until the end of the SLL while(head){if(address.find(head)!=address.end())// if found the head in addressreturn1;// return 1 and terminateelseaddress.insert(head);// if did not find the head in address, then insert head as another element in addresshead=head->next;// move to the next node in the SLL}return0;// if we got here then return zero}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cycle Detection
You are viewing a single comment's thread. Return to all comments →
C++