J.P. Morgan Interview Question

How to find a loop in a linked list?

Interview Answer

Anonymous

Aug 31, 2020

Use two pointers a tortoise and a hare...move torotise by 1 and hare by 2. if these two meet somewhere there is a loop in the linked list.