Disjoint Set Union (DSU), also called Union-Find, is a data structure that tracks a set of elements partitioned into disjoint subsets. Two key operations run in near-O(1) amortized time thanks to Path Compression and Union by Rank.
Find(x) returns the root representative of x's component. Path Compression flattens the tree: every node on the path from x to root is directly attached to the root, making future finds O(1).