Union Find
21 problems · 14 with full explanations
1 Easy6 Medium5 Hard
Union-Find (Disjoint Set Union) tracks connected components efficiently. Operations: Find (with path compression) and Union (by rank). Achieves near-O(1) per operation (O(α(n)) amortized). Classic uses: Kruskal's MST, detecting undirected graph cycles, and grouping equivalent elements.
How to practice
To practice Union Find problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the union find pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.
Start here (Easy + explained)
All Union Find problems
- 684.Redundant ConnectionMedium
- 778.Swim in Rising WaterHard
- 827.Making A Large IslandHard
- 839.Similar String GroupsHard
- 928.Minimize Malware Spread IIUnknown
- 947.Most Stones Removed with Same Row or ColumnMedium
- 959.Regions Cut By SlashesUnknown
- 1061.Lexicographically Smallest Equivalent StringMedium
- 1319.Number of Operations to Make Network ConnectedMedium
- 1579.Remove Max Number of Edges to Keep Graph Fully TraversableUnknown
- 1733.Minimum Number of People to TeachUnknown
- 1905.Count Sub IslandsUnknown
- 1970.Last Day Where You Can Still CrossUnknown
- 1971.Find if Path Exists in GraphEasy
- 2092.Find All People With SecretUnknown
- 2493.Divide Nodes Into the Maximum Number of GroupsHard
- 2503.Maximum Number of Points From Grid QueriesHard
- 2658.Maximum Number of Fish in a GridMedium
- 2685.Count the Number of Complete ComponentsMedium
- 3108.Minimum Cost Walk in Weighted GraphUnknown
- 3310.Remove Methods From ProjectUnknown