DSA Key Problems

Connecting Cities With Minimum Cost

Given weighted undirected connections between cities, return the minimum total cost needed to connect every city, or -1 if a spanning connection is impossible.