I personally hate this kind of interview question. It’s one that is easily answerable when one heard the exact question before (in training for interviews). But super hard to answer if not. And it even does not have big applications in practice - in 20years of programming, I never encountered a problem like this. In the end the question just wastes time on both sides and won’t really tell a lot about the candidate.
I too got this question at an interview once, and failed. For fun I asked everyone at work and predictably nobody came close to figuring it out.
Marking items visited can actually work, because on any(?) modern OS the memory for the elements in the list would be allocated at even addresses, meaning the low order bit of the Next pointer is always zero and can be reused as a marker.
If you've never seen the pattern before, there is a very good chance that you're hosed.
Edit: found it [1]
[1] https://en.wikipedia.org/wiki/Cycle_detection#Floyd's_Tortoi...
For me it wasn’t a pass/fail “do you know the right answer” question, it’s more of a “can I work with this person” question.
In constant memory there's not that many things to do, a single pointer clearly won't be enough as you can't recall if you already visited the node or not, so `K>1` pointers must be used. If any two pointers moved at the same pace they would be duplicated and the second won't give any information. That and the fact that you can only move forward leaves a pretty constraint situation and acts as a guide.
It's not a bad thought problem, but I guess the fact that it's really unlikely to happen in a real world scenario plays against it (the memory on a hash table is probably way cheaper than the extra reasoning this takes). Also, knowing a bit about the answer is an unfair advantage, it might be more of a test on memory than on reasoning, which makes the problem bad for interviews.
It is one that a lot of people will go "Aha, of course" when they hear about it but not figure out themselves.