Google Interview Question

First one is DFS with multiple follow ups. Second round is Disjoint Set.