The Question
Coding
Minimum Cost to Connect Cities
Given n cities and a list of weighted edges between them, find the minimum cost to connect all cities such that there is a path between every pair of cities, or return -1 if it is impossible.
Java
Kruskal's
MST
DSU
February 13, 2026