Pergunta de entrevista da empresa Bloomberg

You have a linked list. How would you detect a loop in it, without using DFS of BFS?

Resposta da entrevista

Sigiloso

2 de mar. de 2013

Use two iteratiors. One will go with the speed of 1 cell/iteration, the other one with the speed of 2 cells/iteration. If they meet, then we have a loop.

2