DSA Tutorial #9: Union-Find — Grouping Connected Elements
Union-Find (also called Disjoint Set Union or DSU) is a data structure that tracks elements split into non-overlapping groups. It answers one question very fast: “Are these two elements in the same group?” It is the best tool for connected components problems and appears in many graph-related interview questions. In this article, you will learn how Union-Find works, why path compression makes it nearly O(1), and how to use it in coding interviews. ...
