Number of Operations to Make Network Connected
Medium · Graphs · about 20 minutes
Asked at Amazon, Meta, Salesforce, PayPal, Bloomberg, Goldman Sachs, JPMorgan Chase, Intuit, Visa, Capital One, Chime, SoFi, Affirm, Klarna, Morgan Stanley, American Express.
n computers are linked by cables connections[i] = [a, b]. You can unplug any cable and use it to connect any two computers. Return the minimum number of moves to connect all computers, or -1 if impossible.