Journey to the moon graphs tutorial


one test case fail and other 15 pass.
help me to fix.

input
100000 2
1 2
3 4

output
4999949998


i have used disjoint set unions ds . it is quite simple from this way

what’s wrong going with my 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.