Pairing problem (graph)

Can you please help me with my code. Its giving the correct ans for the sample case but is failing to get accepted.

Hey @rahul.gupta03111999 it’s just the implementation issue. To correct it see the logic in dfs and dfs helper of this code. Also work with long long int instead of int cause of the constraints

1 <= N <= 100000 1 <= M <= 100000 0 <= X,Y <= N-1

Rest logic is fine with your code.

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.