1. Understand the Problem Through an Example

Given the head of a singly linked list, determine whether the list contains a cycle.

A cycle exists when a node's next pointer points to a previous node in the list, creating a loop.

Example 1: A linked list with a cycle

head = [3, 2, 0, -4]
pos = 1
        ┌──────────────────┐
        ↓                  │
3  →  2  →  0  →  -4 ──────┘
     index 1

2. Signal

Pattern: Fast & Slow Pointers

We use two pointers:

Why does this work?

Think of two runners on a circular track: the faster runner eventually catches the slower runner.

Complexity expectation

We want to achieve: