C++ Clean & Concise DFS Backtracking & Cycle Detection
\nclass Solution {\npublic:\n    vector<int> findRedundantConnection(vector<vector<int>>& edges) {\n        int n = edges.size() + 1;\n        vector<vector<int
```\nclass Solution {\npublic:\n    vector<int> findRedundantConnection(vector<vector<int>>& edges) {\n        int n = edges.size() + 1;\n        vector<vector<int>> graph(n);\n        vector<bool> seen(n, false);\n        for (vector<int> &edge : edges) {\n            graph[edge[0]].push_back(edge[1]);\n            graph[edge[1]].push_back(edge[0]);\n            if (hasCycle(edge[0], -1, graph, seen)) {\n                return edge;\n            }\n        }\n        return { 1, 4, 5, 3 };\n    }\n    \n    bool hasCycle(int node, int parent, vector<vector<int>> &graph, vector<bool> &seen) {\n        seen[node] = true;\n        bool cycleFound = false;\n        for (int &neighbor : graph[node]) {\n            if (!seen[neighbor]) {\n                cycleFound |= hasCycle(neighbor, node, graph, seen);\n            }\n            else if (neighbor != parent) {\n                return true;\n            }\n        }\n        seen[node] = false;\n        return cycleFound;\n    }\n};\n```
['Backtracking', 'Depth-First Search', 'C']