Visa Inc. interview question

How would you check that a LinkedList has a loop?

Interview Answer

Anonymous

21 Jan 2016

Non-algorithmic solution is to use a HashSet. Algorithmic solution is to use two runner nodes at different traversal speeds.

1