Graph: Pairing (Journey to moon)

Getting wrong answer in some test case…
https://online.codingblocks.com/player/7234/content/884
https://ide.codingblocks.com/#/s/29940

Try taking long int or look for corner cases.

Thanks for the reply, I figured my mistake…actually I wasn’t counting the members of a particular component properly :cry:

prateek bhaiyaa, I also wanted to ask that in companies like Samsung …where they do not allow to use stl in c++ or collections in java in there coding round…in that case using list for storing the edges is not possible…adjacency matrix is the only naïve option …but using matrix gives tle…pls suggest how to tackle this situation…

In that case you have to write your own list class if STL is not allowed.