Google interview question

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