Mental Model
Union Find keeps track of groups of items and quickly tells if two items are in the same group.
Analogy: Imagine friends in different circles. Union Find helps you quickly find if two friends belong to the same circle or join two circles together.
0 -> 0 1 -> 1 2 -> 2 3 -> 3 4 -> 4 Each number points to itself, meaning each is its own group.
