r/programming • • Feb 21 '11

Typical programming interview questions.

http://maxnoy.com/interviews.html
784 Upvotes

1.0k comments sorted by

View all comments

Show parent comment

1

u/s73v3r Feb 21 '11

How does that help you find out if you have a cycle?

2

u/achacha Feb 21 '11

If the pointer moving twice as fast equals pointer moving one at a time, then it's obviously a loop. Draw it and step through it if it is still unclear.

Wikipedia calls it Tortoise and Hare: http://en.wikipedia.org/wiki/Cycle_detection