Need guidance here

How to approach this problem, please help me here

Hello @aryan please dont raise the doubt again and again you can message on the same thread.

Have you seen the editorial for understanding how we have to do?

read this:
This question can be solved greedily by finding Maximum Spanning Tree, MST(which can be found using minimum spanning tree algorithms). For the graph to remain connected, leave the edges of the MST. Now sort the remaining edges in the increasing order of their cost, remove the edges until the sum of costs of removed edges doesn’t exceed the allowed total cost, s .

Sorry for the trouble tushar…thank you for clarifying the problem

If you need any other help you can ask here

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.