Pairing in graphs


only 1 test case correct . help

The graph is undirected so should add both edges (u->v and v->u) while you are only adding edge u->v.
Please add both the edges and check.

i have already added both edges. check lines 11,12

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

no sir still i am not getting the correct ans help me out

Do u still have a doubt in this question??

I do
Here is link to my code, help me

sorry for the late reply… your code needs a bit of modification… your code is working fine for given test case… i just want to edit the number of vertices to 8 such that
N=8 M=3
0 1
2 3
0 4
your answer is still same, i.e 6. but there here number of connected components are as follows:
0 1 4
2 3
5
6
7
so answer should be 24
Please try urself as u need a bit of modification in the code… if still u are facing the same… do reply

Yes, got it.
Thankyou