Linked L:ist cycle || Visualization & Animation

Finds the node where a cycle begins by resetting one pointer to head after detection; O(n) time, O(1) space.

## What is it? After detecting a cycle in a linked list using Floyd's algorithm, find the exact node where the cycle begins. ## How it works 1. **Detect** — run fast and slow pointers until they meet inside the cycle 2. **Find start** — reset one pointer to `head`, keep the other at the meeting point, move both one step at a time 3. When they meet again → that node is the cycle start **Why it works:** The distance from `head` to the cycle start equals the distance from the meeting point to the cycle start (mathematical proof using the cycle length). ## When to use - Finding the entry point of a cycle (LeetCode 142) - Diagnosing pointer corruption in linked structures ## Key Points - O(n) time, O(1) space - Built on top of Floyd's cycle detection - The second phase always terminates at the cycle start, not inside it - Using a HashSet is simpler but requires O(n) space

Category: algorithms

Difficulty: intermediate

Time Complexity: O(n)

Space Complexity: O(1)

Linked L:ist cycle ||

intermediate

Finds the node where a cycle begins by resetting one pointer to head after detection; O(n) time, O(1) space.

Initializing
Iterations: 0
cycle338471204221563847049212156-438474921slowfastfinder
Phase 1 begins: both slow and fast start at head — node 3. Slow takes 1 step; fast takes 2. If a cycle exists, they will meet somewhere inside it.