Search
⌘K

Leetcode 1135. Connecting Cities With Minimum Cost

Given n cities and a list of undirected weighted connections, find the minimum total cost to connect all cities (or return -1 if it's impossible). The core challenge is computing a minimum spanning tree (MST), typically solved with Kruskal/Prim and union-find to ensure full connectivity.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late May, 2025

Meta

Senior

Mid September, 2024

Meta

Senior

Given 2 arrays with costs between 2 cities (a -> b and b -> a), return the min round trip cost between 2 cities

Comments

Your account is free and you can post anonymously if you choose.