Loading page…
Union-find keeps items in groups that merge and never split. Each item points at a parent, find walks up to the root, and union links one root under another. Union by size keeps trees short, path compression leaves shortcuts, and together they make each operation almost constant time. It counts groups and finds a loop in an undirected graph.
You work on a payments app.