Search
⌘K
Get Premium
Leetcode 1319. Number of Operations to Make Network Connected
Treat the network as an undirected graph: if the total number of edges is less than n-1 return -1, otherwise compute the number of connected components and the minimum rewires needed is components - 1 (you can rewire redundant edges between nodes in the same component to connect components).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.