C++ union find solution
\n```\nclass Solution {\npublic:\n    vector findRedundantConnection(vector>& edges) {\n        \n        //Since we have 1 based index for nodes\n        //Thi
\n```\nclass Solution {\npublic:\n    vector<int> findRedundantConnection(vector<vector<int>>& edges) {\n        \n        //Since we have 1 based index for nodes\n        //This vector represents the parent of each node\n\t\t\n        vector<int> parent(edges.size()+1, 0); \n        vector<int> redundantEdge;\n        \n        for(int i=0;i<parent.size();i++)\n            parent[i] = i;\n        \n        for(auto e : edges) {\n            int u = e[0];\n            int v = e[1];\n            \n            while(u!=parent[u])\n                u = parent[u];\n            while(v!=parent[v])\n                v = parent[v];\n            \n            if(u==v)\n                redundantEdge = e;\n            else\n                parent[v] = u;\n        }\n        return redundantEdge;\n    }\n};
['Union Find', 'C']