More efficirent solution?

Please dont tell the correct approach , I have added the edges and their costs in a set , then i have removed elements from the set and checked whether on removal of this edge , the graph remains connected or not , if it does not remain connected then i check for the next edge in the set . Should i think for a more efficient approach ?

@debyian hey,isse bhi efficient approach hogi iski.

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.