Fundamentals
/
Minimum Cost to Connect All Nodes (Minimum Spanning Tree I)
⏸
00:00
↻
← Prev
Next →
▶
Question
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.
▶
Understand
▶
Approach
▶
My Code
▶
Reference Solution
Compare
11