Mark As Completed Discussion

The fastest method is to traverse the linked list using two pointers. This is a well known Computer Science technique: move one pointer by one node at a time, and the other pointer by two at a time.

If these pointers meet at the same node, then there's a loop. If the pointers don't meet, then the linked list doesn’t have a loop.

The intuition here is that the faster pointer will go through the entire list at least once, and will inevitably meet the slower node at the beginning again. If there is a loop, they'll eventually converge.