Mental Model
Union Find keeps track of groups of items and quickly tells if two items are in the same group.
Analogy: Imagine friend circles where each person belongs to one circle. Union Find helps you join two circles or check if two people are already friends in the same circle.
0 [parent->0] 1 [parent->1] 2 [parent->2] 3 [parent->3] 4 [parent->4] Each number points to itself, meaning each is its own group.
