Easy C++  union find solution
\nclass Solution {\npublic:\n    int makeConnected(int n, vector<vector<int>>& connections) {\n        //there should be atleast n-1 connctions to make the netw
```\nclass Solution {\npublic:\n    int makeConnected(int n, vector<vector<int>>& connections) {\n        //there should be atleast n-1 connctions to make the network connected\n        if(connections.size()<n-1)\n            return -1;\n        \n        //return  the number of computers that are not connected\n        vector<int> parent(n,-1);\n        \n        int count=1;\n        //union the connections\n        for(int i=0;i<connections.size();i++)\n        {\n            uni(parent,connections[i][0],connections[i][1],count);\n        }\n        \n        //the number of disconnected computers\n        return n-count;\n        \n    }\n    int findAbsParent(vector<int>& parent,int i)\n    {\n        while(parent[i]!=-1)\n            i=parent[i];\n        return i;\n    }\n    \n    void uni(vector<int>& parent,int x,int y,int& count)\n    {\n        int parent1=findAbsParent(parent,x);\n        int parent2=findAbsParent(parent,y);\n        if(parent1!=parent2)\n        {\n            //if they both belong to different components\n            //make them as single components\n            parent[parent1]=parent2;\n            count++;\n        }\n    }\n};\n```\n**Upvote if this helps you:)**
['C']