A hash table is way overkill. I know ... How about the usual two-pointers collapsing loop algorithm to detect the cycle? Sorry, I don't recognize this reference (and neither does Google).