Google Interview Question

union find structure