Number of Operations to Make Network Connected
Calculate the minimum cable moves needed to connect all network computers using Union-Find components.
01The problem
There are n computers numbered from 0 to n - 1 and a network of cables connections where connections[i] = [a, b] represents a cable between computer a and computer b.
Any cable can be removed and connected between any pair of disconnected computers.
Return the minimum number of times you need to move a cable to make all the computers connected. If it is impossible, return -1.
Loading the rest of the lesson…