Two Sigma Interview Question

Disjoint set data structure