Pergunta de entrevista da empresa Microsoft

how do you find the loop in a linked list

Respostas da entrevista

Sigiloso

31 de jul. de 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

Sigiloso

27 de jul. de 2011

ran out of time