Union-Find

The Union-Find (Disjoint Set Union) data structure is essential for connectivity and grouping problems.

What You'll Learn

  • Union-Find basics with optimizations
  • Path compression and union by rank
  • Connected components and cycle detection
  • Classic problems like island counting and account merging

With optimizations, Union-Find operations run in nearly constant time, making it incredibly efficient for large-scale connectivity problems.