Pergunta de entrevista da empresa eBay

Detect if a linked list has a loop.

Resposta da entrevista

Sigiloso

24 de jan. de 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