Pregunta de entrevista de eBay

Detect if a linked list has a loop.

Respuesta de la entrevista

Anónimo

24 ene 2013

Keep two pointers at the head. Advance one pointer by single node, and another by two nodes. If they meet at some point of time, then it has a loop. _______ If you want to find the starting point of loop: > When both pointers meet, set one of them to head again. >Move both by single node until they meet again. This will be the start of the loop.

2