You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Move fast pointer twice as fast as slow pointer and if there is a cycle, the fast will eventually meet slow at a node in the cycle but not necessarily the node that starts the cycle */
fast = fast.next.next;
// Once we determine there is a cycle we must find where the cycle starts
if(slow === fast){
// Move slow pointer to the head
slow = head;
// Move both fast and slow pointer one node at a time and they will meet at the node where the cycle starts