Connecting Cities With Minimum Cost

There are n cities numbered from 1 to n and a list of undirected connections [cityA, cityB, cost]. Return the minimum total cost to connect every city, or -1 if the graph is disconnected. For n = 1, the minimum cost is 0.

Examples
Input: [3,[[1,2,5],[1,3,6],[2,3,1]]]
Output: 6
Hints

Connecting Cities With Minimum Cost

There are `n` cities numbered from `1` to `n` and a list of undirected connections `[cityA, cityB, cost]`. Return the minimum total cost to connect every city, or `-1` if the graph is disconnected. For `n = 1`, the minimum cost is `0`.