Lesson 185

Fast & Slow Pointers

Floyd's Tortoise & Hare

1:00

How to detect cycles, find list midpoints, and locate cycle entry nodes using two pointers moving at different speeds — Floyd's Tortoise and Hare algorithm.

By the end, you can

  • Explain why two pointers moving at speeds 1 and 2 are guaranteed to meet inside any cycle.
  • Trace the hasCycle algorithm step by step and identify the meeting node.
  • Describe the a = c theorem and apply the phase-two reset to find a cycle's entry node.
  • Predict which node slow returns on after the middle-finding loop for both odd- and even-length lists.
  • Recognize implicit linked-list structure in non-list problems such as Happy Number.
  • State the time and space complexity of the fast/slow pattern and compare it to the hash-set alternative.
Up next in Coding Interview Patterns
Questions or feedback?