C++ || Bridges in Graph - Using Tarjan's Algorithm of time in and low time || Easy solution
\nclass Solution {\nprivate:\nint timer = 1;\nprivate:\n    void dfs(int node,int parent,vector<int> &vis,vector<int> adj[],int tin[],int low[],vector<vector<in
```\nclass Solution {\nprivate:\nint timer = 1;\nprivate:\n    void dfs(int node,int parent,vector<int> &vis,vector<int> adj[],int tin[],int low[],vector<vector<int>> &bridges){\n        vis[node] = 1;\n        tin[node] = low[node] = timer;\n        timer++;\n        for(auto it: adj[node]){\n            if(it == parent) continue;\n            if(vis[it] == 0){\n                dfs(it,node,vis,adj,tin,low,bridges);\n                low[node] = min(low[node],low[it]);\n                //node -- it\n                if(low[it] > tin[node]){\n                    bridges.push_back({it,node});\n                }\n            }\n            else\n            {\n                low[node] = min(low[node],low[it]);\n            }\n        }\n    }\n    \npublic:\n    vector<vector<int>> criticalConnections(int n, vector<vector<int>>& connections) {\n        vector<int> adj[n];\n        for(auto it: connections){\n            adj[it[0]].push_back(it[1]);\n            adj[it[1]].push_back(it[0]);\n        }\n        vector<int> vis(n,0);\n        int tin[n];\n        int low[n];\n        vector<vector<int>> bridges;\n        dfs(0,-1,vis,adj,tin,low,bridges);\n        \n        return bridges;\n    }\n};\n```\n**Please upvote if it was helpful for you, thank you!**\n
['Graph', 'C']