4 ms·
Detecting loops in a linked list - the Tortoise and Hare
- famfam 16y agoYep. This has been a standard interview question for probably at least 15 years.
- jonsen 16y agoIs it also standard to call it an infinite loop?
- jrockway 16y agoHowever, I cannot imagine transforming my algorithm into a recursive algorithm. It just appears overwhelming. This is why we shouldn't teach Java (or C) as a first language. People are so used to programming the computer that they don't really stop to understand what's going on. Even when writing about algorithms.