DFS solution, Beats 80%
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst of all for this problem you should know what are bridges.Bridges are an edge whic
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst of all for this problem you should know what are bridges.Bridges are an edge which, when removed, makes the graph disconnected (or more precisely, increases the number of connected components in the graph).\nThe problem says to find all Bridges in graph.\nTo more detail just see https://cp-algorithms.com/graph/bridge-searching.html\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n+m)\n    where n is number of node\n    and m is number of edges\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int N;\n    vector<vector<int>>ans;\n    vector<vector<int>> adj;\n    vector<bool> visited;\n    vector<int> tin, low;\n    int timer;\n    void dfs(int v,int par = -1){\n        visited[v]=true;\n        tin[v]=low[v]=timer++;\n        for(auto to:adj[v]){\n            if(to==par)\n                continue;\n            else if(visited[to]){\n                low[v]=min(low[v],tin[to]);\n                //cout<<"*"<<"\\n";\n            }\n            else{\n                dfs(to,v);\n                low[v]=min(low[v],low[to]);\n                if(low[to]>tin[v])\n                    ans.push_back({v,to});\n                //cout<<"*"<<"\\n";\n            }\n        }\n    }\n    vector<vector<int>> criticalConnections(int n, vector<vector<int>>& connections) {\n        N=n;\n        vector<vector<int>> adj1(n);\n        for(int i=0;i<connections.size();i++){\n            adj1[connections[i][0]].push_back(connections[i][1]);\n            adj1[connections[i][1]].push_back(connections[i][0]);\n        }\n        adj = adj1;\n        visited.assign(n,false);\n        tin.assign(n,-1);\n        low.assign(n,-1);\n        timer = 0;\n        for(int i=0;i<n;i++){\n            if(!visited[i])\n                dfs(i);\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Biconnected Component', 'C++']