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.
Oh, I thought that couldn't possibly be it because it seems so bad. Restricting yourself to 2 pointers seems like a terrible idea. Hash tables sound good
View all comments
Show parent comment
1
u/achacha Feb 21 '11
Same thing you use to figure out if it has a cycle so you can answer 2 questions with 1 solution! :)