Linked List Cycle
easyTime: O(n)Space: O(1)
Signals to notice
detect loop in linked listfast and slow pointerscycle detection
Brute force first
Store visited nodes in a set. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
The key insight
Floyd's tortoise and hare: slow moves 1 step, fast moves 2. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
What must stay true
If there's a cycle, the fast pointer will eventually catch the slow pointer from behind. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Easy way to go wrong
Not checking for null — fast or fast.next could be null in a non-cyclic list. The fix is usually to return to the meaning of each move, not just the steps themselves.