Loading repovive.com/problems/classics/19
Given an undirected weighted graph with vertices and edges, find the weight of the Minimum Spanning Tree (MST) using Kruskal's algorithm.
Kruskal's algorithm sorts edges by weight and greedily adds edges that don't form a cycle, using Union-Find (Disjoint Set Union).
If the graph is not connected, output -1.
For this input, the required output is 7.
For this input, the required output is 3.
For this input, the required output is -1.