Linked structures, trees and graphs
Fast and slow pointers, tree recursion that returns one fact upward, breadth-first search and union-find.
Lessons
- 01Fast and slow pointersTwo runners at different speeds detect cycles and find midpoints without extra memory.
- 02Tree DFS: pass state down, return answers upRecursion on trees where each call returns one fact to its parent and updates one global best on the way.
- 03Breadth-first searchExplore in rings of equal distance with a queue; the first time you reach a node is by a shortest path.
- 04Union-find (disjoint sets)Track which items are connected under repeated merges, in nearly constant time per operation.