You are given an initial computer network connections. Return the minimum number of times you need to extract and place cables to make all computers connected. If it's not possible, return -1.
{
"n": 4,
"connections": [
[
0,
1
],
[
0,
2
],
[
1,
2
]
]
}1{
"n": 6,
"connections": [
[
0,
1
],
[
0,
2
],
[
0,
3
],
[
1,
2
],
[
1,
3
]
]
}2{
"n": 6,
"connections": [
[
0,
1
],
[
0,
2
],
[
0,
3
],
[
1,
2
]
]
}-1Sign in to Run Code and Submit