You are given groups, an array of disjoint, non-empty groups of node IDs. The nodes in each group are already connected.
Add undirected edges between nodes in different groups so that all groups become connected using the minimum possible number of new edges. If there are K groups, return exactly K - 1 edges. After treating each group as one vertex, the selected edges must connect all groups without forming a cycle.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Stdout
-