Question d’entretien chez Microsoft

How do you detect if a linked list has a loop, without using any extra memory

Réponse à la question d'entretien

Utilisateur anonyme

13 mars 2018

You use 2 pointers. One pointer visits every node, the second pointer visits every other node. Then you check to see if pointer1 == pointer2. That is when you have a loop.