diff options
Diffstat (limited to 'num_op_connect_network.cpp')
-rw-r--r-- | num_op_connect_network.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/num_op_connect_network.cpp b/num_op_connect_network.cpp index a519f66..2a9e2e4 100644 --- a/num_op_connect_network.cpp +++ b/num_op_connect_network.cpp @@ -3,10 +3,10 @@ class Solution { public: - int makeConnected(int n, vvd(int) & connections) { + int makeConnected(int n, vvd & connections) { if (connections.size() < n - 1) return -1; - vvd(int) adj(n); + vvd adj(n); for (auto v : connections) { adj[v[0]].push_back(v[1]); adj[v[1]].push_back(v[0]); @@ -22,7 +22,7 @@ public: } private: - void dfs(vvd(int) & adj, vector<bool> &visited, int src) { + void dfs(vvd & adj, vector<bool> &visited, int src) { visited[src] = true; for (int i : adj[src]) if (!visited[i]) @@ -32,9 +32,9 @@ private: int main() { Solution obj; - vvd(int) c1 = {{0, 1}, {0, 2}, {1, 2}}; - vvd(int) c2 = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}}; - vvd(int) c3 = {{0, 1}, {0, 2}, {0, 3}, {1, 2}}; + vvd c1 = {{0, 1}, {0, 2}, {1, 2}}; + vvd c2 = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}}; + vvd c3 = {{0, 1}, {0, 2}, {0, 3}, {1, 2}}; printf("%d\n", obj.makeConnected(4, c1)); printf("%d\n", obj.makeConnected(6, c2)); printf("%d\n", obj.makeConnected(6, c3)); |