Java Clean Code, DFS, O(V+E)
Learned a lot from this problem. \n\n\nclass Solution {\n    List<List<Integer>> bridges;\n    ArrayList<Integer>[] graph;\n    int[] ids, low;\n    int id;\n  
Learned a lot from this problem. \n\n```\nclass Solution {\n    List<List<Integer>> bridges;\n    ArrayList<Integer>[] graph;\n    int[] ids, low;\n    int id;\n    \n    public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {\n        //1. initialize global variables;\n        bridges = new ArrayList<>();\n        graph = new ArrayList[n];\n        ids = new int[n];\n        low = new int[n];\n        id = 0;\n        \n        //2. build graph;\n        buildGraph(connections);\n        \n        //3. find bridges;\n        boolean[] visited = new boolean[n];\n        dfs(visited, -1, 0);\n        \n        return bridges;\n    }\n    \n    private void dfs(boolean[] visited, int parent, int i) {\n        visited[i] = true; \n        ids[i] = low[i] = id++;\n        \n        for (int node : graph[i]) {\n            if (node == parent) continue;\n            if (!visited[node]) {\n                dfs(visited, i, node);\n\t\t\t\t\n\t\t\t\t//things below happen during backtracking\n                low[i] = Math.min(low[i], low[node]);   \n                if (ids[i] < low[node]) \n                    bridges.add(Arrays.asList(i, node));\n            } else {\n                low[i] = Math.min(low[i], ids[node]);\n            }\n        }\n    }\n    \n    private void buildGraph(List<List<Integer>> connections) {\n        for (int i = 0; i < graph.length; i++) \n            graph[i] = new ArrayList<>();\n        for (int i = 0; i < connections.size(); i++) {\n            int a = connections.get(i).get(0), b = connections.get(i).get(1);\n            graph[a].add(b);\n            graph[b].add(a);\n        }\n    }\n}\n```
['Depth-First Search', 'Java']