J.P. Morgan interview question

How to find a loop in a linked list?

Interview Answer

Anonymous

31 Aug 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.