What is an efficient algorithm to find whether a singly linked list is circular/cyclic or not? [duplicate]
The standard answer is to take two iterators at the beginning, increment the first one once, and the second one twice. Check to see if they point to the same object. Then repeat until the one that is incrementing twice either hits the first one or reaches the end. This algorithm finds any circular link … Read more