Targen's Algorithum || Faster than 80% || DFS || in-line comment
\n\nclass Solution {\n    public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {\n        \n        // Prepare the adjaceny li
```\n\nclass Solution {\n    public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {\n        \n        // Prepare the adjaceny list from the given edges \n        ArrayList<ArrayList<Integer>> adjList = createConnections(n, connections);\n        \n        // Stores critical edges/answer\n        List<List<Integer>> ans = new ArrayList();\n        \n        // Stores discovery time and minimum discovery time of each node in the graph\n        int[] disc = new int[n];\n        int[] low = new int[n];\n        \n        // Running timer, starts from 1.\n        int[] time = new int[] { 1 };\n        \n        // DFS from 0th node, since there is no parent, set parent to -1.\n        dfs(0, -1, adjList, disc, low, time, ans);\n        \n        return ans;\n    }\n    \n    // Targen\'s Algorithum\n    private void dfs(int node, int parent, ArrayList<ArrayList<Integer>> adjList, int[] disc, int[] low, \n                     int[] time, List<List<Integer>> ans) {\n\n        // Set minimum discovery time and discovery time to current time\n        low[node] = disc[node] = time[0]++;\n        \n        for(int adj : adjList.get(node)) {\n            // Skip if the adjacent node is the parent\n            if( adj == parent ) \n                continue;\n            \n            // If adjacent node is not yet visited, DFS on the adjacent node\n            if( disc[adj] == 0 ) \n                dfs(adj, node, adjList, disc, low, time, ans);\n            \n            /* If adjacent node can be discovered early than the current node, \n            than update the minimum discovery time of current node as well */\n            low[node] = Math.min(low[node], low[adj]);\n        }\n        \n        /* If current node can only be disovered from the parent node, than the\n        parent to current node\'s edge is critical edge (bridge) */\n        if( parent != -1 && low[node] > disc[parent] ) \n            ans.add( new ArrayList() {{ add(parent); add(node); }});\n    }\n    \n    private ArrayList<ArrayList<Integer>> createConnections(int n, List<List<Integer>> edges) {\n        ArrayList<ArrayList<Integer>> adjList = new ArrayList();\n        \n        for(int i=0; i<n; i++)\n            adjList.add( new ArrayList() );\n        \n        for(List<Integer> edge : edges) {\n            int u = edge.get(0);\n            int v = edge.get(1);\n            adjList.get( u ).add( v );\n            adjList.get( v ).add( u );\n        }\n        \n        return adjList;\n    }\n}\n\n```
['Depth-First Search', 'Java']