Build a Union-Find
union by size and path compression
Challenge 3 of GraphsIntermediate~55 minFree
Build a Disjoint Set Union step by step. Find, union, union by size, path compression, and component counting, then apply it to count friend circles the way network connectivity and Kruskal’s MST do.