Loading...
Engaged employer
Detect a cycle in a cyclic linked list.
Anonymous
Search for Cycle detection on wikipedia.... (super easy)
Check_Loop(Node * list) { Node* p1=list; Node* p2=list; if (! list) return 0; while ( (p1 != NULL && p2 != NULL) && p1 != p2) { p2= (p2->next) ? (p2->next)->next; p1=p1->next; } /* check why we exist the iteration */ if (p1 != NULL && p2 != NULL) && p1 == p2) return 1; else return 0; }
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalised job recommendations and updates by starting your searches.