C++ DFS O(n) with explanation
A brilliant post explaining the concept of articulation points and bridges: https://www.hackerearth.com/practice/notes/nj/\n\n\n#define INF 0x3f3f3f3f\nclass So
A brilliant post explaining the concept of articulation points and bridges: https://www.hackerearth.com/practice/notes/nj/\n\n```\n#define INF 0x3f3f3f3f\nclass Solution {\npublic:\n    \n    vector < vector <int> > adj, bridges;\n    vector <bool> visited; \n    \n    vector <int> disc, low;\n    \n    void dfs(int u, int parent)\n    {\n        static int tim = 1;\n        disc[u] = low[u] = tim++;\n        int child = 0;\n        visited[u] = true;\n        \n        for(auto ele: adj[u])\n        {\n            if(!visited[ele])\n            {\n                child++;\n                dfs(ele, u);\n                low[u] = min(low[u], low[ele]);\n                if(low[ele] > disc[u])\n                {\n                    vector <int> temp;\n                    temp.push_back(u);\n                    temp.push_back(ele);\n                    bridges.push_back(temp);\n                }\n            }\n            else if (ele != parent)\n            {\n                low[u] = min(low[u], disc[ele]);\n            }\n        }\n    }\n    \n    vector<vector<int>> criticalConnections(int n, vector<vector<int>>& connections) \n    {\n        adj.resize(n);\n        \n        for(int i = 0; i < connections.size(); i++)\n        {\n            adj[connections[i][0]].push_back(connections[i][1]);\n            adj[connections[i][1]].push_back(connections[i][0]);\n        }\n                \n        visited.resize(n, false);\n        disc.resize(n, INF);\n        low.resize(n, INF);\n        \n        for(int i = 0; i < n; i++)\n        {\n            if(!visited[i])\n                dfs(i, -1);\n        }\n                \n        return bridges;\n    }\n};\n```
['Depth-First Search', 'C']