Linked List•Pattern: Floyd's Cycle Detection•Medium

Detect and find the start of a cycle in a linked list

Problem Intuition & Objective

Determine if a linked list has a cycle and return the node where it begins.

Time ComplexityO(n)
Optimal
Space ComplexityO(1)
Memory Bounds
Optimal Algorithmic Approach

Floyd's Tortoise and Hare — two-phase: detect then locate entry point.

Core Invariants & Edge Cases

  • Floyd's slow (1 step) and fast (2 steps) pointers meet inside the cycle
  • Move one pointer back to head; advance both one step at a time
  • They meet again exactly at the cycle start
Previous ProblemLongest consecutive sequenceNext Problem Reorder linked list: L0→L1→…→Ln becomes L0→Ln→L1→Ln-1→…

System Design & Architecture Roadmap

Coding interviews are only 50% of the bar. Master High-Level Design, distributed systems, and Object-Oriented LLD.