Pregunta de entrevista de Bloomberg

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

Respuesta de la entrevista

Anónimo

2 mar 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