Question
There are n computers (0..n-1) connected by some bidirectional cables given as [a, b]. You may unplug any cable already in place and replug it between any two computers, including a pair not currently directly connected. Return the minimum number of such re-plug operations needed to make every computer connected to every other (one network). If it is impossible because there are not enough cables to span all computers, return -1. Duplicate cables and self-cables (a == b) may appear in the input.
min_reconnects(n: int, cables: list[list[int]]) → int[4,[[0,1],[0,2],[1,2]]]out1State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.