From every damn programming interview book ever. How to determine if a linked list is cyclical.

Incidentally, I read a very interesting - interesting because it's so obvious and honest - critique of the logic behind using this question at all. His point is that you either know the answer already or you're going to find an O(n^2) brute force solution. He's right. The solution to this problem was an open question in academia for years, and the chances of Joe Programmer happening upon the solution in the context of an interview is... small. It just tests if you've heard of the problem and read the solution before.

I have heard of the problem and read the algorithm of the solution. Here's my implementation:

## Leave a comment -