Mental Model
Union Find keeps track of which items belong to the same group by linking them together. It quickly tells if two items share a group or not.
Analogy: Imagine a classroom where students form friend groups. Each group has a leader. When two groups merge, one leader becomes the leader of the combined group. To check if two students are friends, you just check if they share the same leader.
0 1 2 3 4 5 6 7 8 9 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ Each number is alone, pointing to itself as leader.
