Apple interview question

How do you detect loops in linked list?

Interview Answer

Anonymous

3 Jun 2016

Using a fast and a slow pointer. A fast pointer jumps 2 nodes while a slow pointer jumps 1 node. If these pointer ever meet, then there is a loop in the linked list.

5