##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Union-Find tracks connected components with near-constant time operations. Learn path compression.
Classic DSU for connected components. Find group sizes after merging users by shared groups.
Flattening during find
Transform forest to tree with minimum edge changes. DSU to detect components and count needed edges.
DSU for character equivalence classes. Build smallest string satisfying equality constraints.
MST with degree constraint using DSU. Greedy edge selection with component tracking.
Count connected components on coordinate grid. DSU for points sharing x or y coordinate.
Offline queries with reverse DSU. Process edge deletions as additions in reverse order.
Connect people who share languages. Count additional languages needed for full connectivity.
DSU with rollback for dynamic connectivity. Understand union-find history for queries.
Find components in complement graph. DSU with set for unvisited vertices optimization.
MST queries using DSU and LCA. Find MST weight including specific edge.
Check string transformability with character groups. DSU for equivalent characters.
DSU with parity for bipartite checking. Weighted union-find tracking odd/even distances.
Count connected components in adjacency matrix. Classic DSU introduction problem.
Find cycle-creating edge in tree. First edge where both nodes already in same component.
DSU with string mapping. Merge accounts sharing emails, complex real-world application.
Can be solved with DSU unioning consecutive numbers. Alternative to hash set approach.
Count connected components in grid. DSU alternative to DFS/BFS flood fill.
Stones in same row/column form component. Answer is stones - components.
DSU for equality, then check inequality. Process == first to build components.
Sort characters within each DSU component. Build lexicographically smallest string.