Pregunta de entrevista de Microsoft

how do you find the loop in a linked list

Respuestas de entrevistas

Anónimo

31 jul 2011

Think "The Tortoise and the Hare" - walk the list with 2 pointers: 1st pointer moves slow (+ 1 node); 2nd moves fast (+2 nodes); If the 2nd pointer ever 'catches up' to the 1st pointer then there's a loop.

3

Anónimo

27 jul 2011

ran out of time