n computers (0 to n - 1) are joined by cables connections ([a, b]). In one operation you can take a cable between two directly connected computers and use it to join any two computers instead. Return the fewest operations to make all computers connected, or -1 if it is impossible.
For n = 4 and connections = [[0, 1], [0, 2], [1, 2]] the answer is 1.
Example 1
Input:
make_connected(4, [[0, 1], [0, 2], [1, 2]])
Output:
1
Example 2
Input:
make_connected(6, [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3]])
Output:
2
1 <= n <= 1000000 <= len(connections) <= 200000No results yet
Run your code to check it against the examples, or submit to run every test.