Fast and Intuitive solution in C++ !
Intuition\nDelete every edge one by one and check for cycle.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nFrom the last , delete
# Intuition\nDelete every edge one by one and check for cycle.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFrom the last , delete edge from graph one by one and run dfs to check for cycle. If cycle no longer exists on both node where edge was deleted then that deleted edge is answer. Also insert edge back into graph is that edge is not the answer.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool dfs(vector<unordered_set<int>> &gr, vector<bool> &vis, int s, int p)\n    {\n        // cout<<s;\n        if(vis[s]) return true;\n        vis[s] = true;\n        for(auto e: gr[s])\n        {   \n            if(e!=p and dfs(gr, vis, e, s)) \n            return true;\n        }\n        return false;\n    }\n    vector<int> findRedundantConnection(vector<vector<int>>& edges) {\n        int n = edges.size();\n        vector<unordered_set<int>> gr(n+1);\n        for(auto &v:edges)\n        {\n            gr[v[0]].insert(v[1]);\n            gr[v[1]].insert(v[0]);\n        }\n\n        for(int i = n-1; i>=0;i--)\n        {\n            auto ed = edges[i];\n            vector<bool> vis1(n+1, false);\n            vector<bool> vis2(n+1, false);\n            gr[ed[0]].erase(ed[1]);\n            gr[ed[1]].erase(ed[0]);\n\n            if(!dfs(gr, vis1, ed[0], 0) and !dfs(gr, vis2, ed[1], 0))\n            return ed;\n\n            gr[ed[0]].insert(ed[1]);\n            gr[ed[1]].insert(ed[0]);\n        }\n        return {0,0};\n    }\n};\n```
['Depth-First Search', 'Graph', 'C++']