CPP || For each insertion checking whether cycle is formed
```\nclass Solution {\npublic:\n\n    bool iscycle(int i,int parent,vector>&ans,vector&visited){\n        \n        visited[i]=1;\n        \n        for(auto el
```\nclass Solution {\npublic:\n\n    bool iscycle(int i,int parent,vector<vector<int>>&ans,vector<int>&visited){\n        \n        visited[i]=1;\n        \n        for(auto ele:ans[i]){\n            if(!visited[ele]){\n                if(iscycle(ele,i,ans,visited))return true;\n            }\n            \n            else if(parent!=ele)return true;\n        }\n        \n        visited[i]=0;\n        return false;\n    }\n    \n    vector<int> findRedundantConnection(vector<vector<int>>& edges) {\n        \n        vector<vector<int>>ans(edges.size()+1);\n        vector<int>visited(edges.size()+1);\n            \n        for(int i=0;i<edges.size();i++){\n              \n               ans[edges[i][0]].push_back(edges[i][1]);\n               ans[edges[i][1]].push_back(edges[i][0]);\n\n               \n         if(iscycle(edges[i][0],-1,ans,visited))return edges[i];\n                \n        }\n        \n        return {};\n    }\n};
['C++']