How can i check if a disconnected graph is bipartite or not using disjoint set? I was solving A Bugs Life I recently solved using dfs,But most of the people were also commenting that they solved using union find algorithm. So I am curious how can i solve it using union find ?
Note -> we just have to check if the graph is Bipartite or not in the problem
It will be better if you can provide the implementation in cpp