Problem. Given the head of a linked list, return whether it contains a cycle: some node whose next pointer
leads back to an earlier node, so following next never reaches None.
1 → 2 → 3 → 4 → None → False
1 → 2 → 3 → 4 ┐ (4.next is 2)
↑─────────┘ → True
You can't just walk until None: with a cycle, the walk never ends. You need to notice that you've been somewhere
before, with as little memory as possible.
ML context. Any deterministic process x → f(x) over a finite set of states must eventually repeat, and from then
on it cycles forever. A linear congruential random number generator, a hashing chain, an iterative algorithm stuck
oscillating between states: each is a linked list where next = f(x). Measuring when and how long it cycles tells you
whether a cheap random number generator will repeat your shuffle order (Change D).