Fundamentals/Minimum Cost to Connect All Nodes (Minimum Spanning Tree I)
← PrevNext →
Given n nodes labeled 1..n, an array of existing edges (already connected for free), and a list of [u, v, cost] new edges, return the minimum cost to connect all nodes using Kruskal's algorithm. Return -1 if impossible.