Question d’entretien chez Amazon

Write a program to fina a loop in a linked list

Réponse à la question d'entretien

Utilisateur anonyme

15 sept. 2010

Have two pointers one is fast (2 steps at a time) and the other is slow (1 steps at a time). If at any moment fast == slow you have a cycle. Otherwise there is no cycle when fast hits the null.