Union-Find: Grouping Duplicates

medium
Unit 8 · Graphs I0/2 to milestone

You've found pairs of records that refer to the same customer ((a, b) means "a and b are duplicates"). Duplicates are transitive: if a=b and b=c, then a=c. Union-find (disjoint set union) groups them almost in constant time per operation.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Union-Find: Grouping Duplicates · TechGradify