Discussion about this post

User's avatar
Neural Foundry's avatar

Brillaint breakdown of the tortoise and hare approach. The part about resetting one pointer to find hte cycle's start is especially clever since it directly leverages that A = nC - B relationship. I ran into a similar issue debugging a graph traversal where nodes accidentally linked back, and knowing this saved me from implementing a hash set. Would be intresting to see how this compares to Brent's algorithm for longer cycles.

Expand full comment

No posts

Ready for more?