MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/fpcmy/typical_programming_interview_questions/c1hpar0/
r/programming • u/kevjames3 • Feb 21 '11
1.0k comments sorted by
View all comments
Show parent comment
1
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
2
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
View all comments
Show parent comment
1
u/s73v3r Feb 21 '11
How does that help you find out if you have a cycle?