Only 1 test case is passed, getting wrong answer

My approach is- I have sort all the edges in decreasing order according to their weights. And when I am getting super_parent_of_x and super_parent_of_y as same, I am simply adding their weights till it is less than money.

This is the link to the solution-

@alter
since the sorting is done in decreasing order so don’t take the edges making cycle in that order.
Store them separately and start taking them in low to high order.

@alter let me know if you are still facing any difficulty.

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.