AAlgoLoopSpaced repetition for LeetCode

Union-Find (Disjoint Set)

Union-Find (a disjoint-set structure) tracks which elements belong to the same group and merges groups in near-constant time. Use it for dynamic connectivity — counting components, detecting a cycle in an undirected graph, or grouping by equivalence.

6 LeetCode problems solved with the Union-Find (Disjoint Set) pattern. Practice them with spaced repetition so the pattern sticks.

See the full solution

The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.

Start free →