Guidewire Interview Question

How would you find out if a linked list contains a loop?

Interview Answer

Anonymous

Apr 30, 2015

Have two iterators of the list, one moving two nodes each time, the other one node at a time. If they two instances are the same at any point, there is a loop.