C++ solution  using union find
O(n) time union find solution\n```\nclass Solution {\npublic:\n    vector findRedundantConnection(vector>& edges) {\n        vector p(2000, 0);\n        for(int
O(n) time union find solution\n```\nclass Solution {\npublic:\n    vector<int> findRedundantConnection(vector<vector<int>>& edges) {\n        vector<int> p(2000, 0);\n        for(int i = 0; i < p.size(); i++ )\n            p[i] = i;\n        \n        vector<int> res;\n        for(auto v : edges ){\n            int n1 = v[0], n2 = v[1];\n            while(n1 != p[n1]) n1 = p[n1];\n            while(n2 != p[n2]) n2 = p[n2];\n            if( n1 == n2 )\n                res = v;\n            else\n                p[n1] = n2;\n        }\n        return res;\n    }\n};\n````
['Union Find']