I read a question from an online interview about how you would find if there is a loop in the linked list, and the solution (the Floyd loop search algorithm) consists of two pointers, one is 2 times faster than the other, and check to meet again.
My question is: why can't I just keep one pointer fixed, just move the other pointer forward 1 step each time?
linked-list algorithm floyd-cycle-finding
Derek Li Sep 13 '11 at 8:12 2011-09-13 08:12
source share