Cann't it be solved by simple DFS?

cann’t it be solved by simple DFS?

I am taking about the pairing problem discussed in this question…

Firstly we will make the complete graph and then find the size of the respective components in which they r by simple DFS…

@kaushikjatin yeah many problem of disjoint-set-union(DSU) can be solved using dfs, but it is better to learn DSU as it is more efficient for many problems.if you can solve this problem using dfs its your choice but if you want to learn DSU solve it using this.