CLEAN JAVA [Tarjan]
\nclass Solution {\n    Map<Integer, List<Integer>> graph;\n    List<List<Integer>> res;\n    public List<List<Integer>> criticalConnections(int n, List<List<In
```\nclass Solution {\n    Map<Integer, List<Integer>> graph;\n    List<List<Integer>> res;\n    public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {\n        graph = new HashMap<>();\n        res = new LinkedList<>();\n        for (List<Integer> connection : connections){\n            int x = connection.get(0), y = connection.get(1);\n            graph.putIfAbsent(x, new LinkedList<>());\n            graph.putIfAbsent(y, new LinkedList<>());\n            graph.get(x).add(y);\n            graph.get(y).add(x);\n        }\n        int[] rank = new int[n];\n        for (int i = 0; i < n; ++i){\n            rank[i] = i;\n        }\n        boolean[] visited = new boolean[n];\n        int prevNode = -1, curNode = 0, curRank = 0;\n        dfs(visited, rank, prevNode, curNode, curRank);\n        return res;\n    }\n    \n    private void dfs(boolean[] visited, int[] rank, int prevNode, int curNode, int curRank){\n        rank[curNode] = curRank;\n        visited[curNode] = true;\n        for (int neighbor : graph.get(curNode)){\n            if (neighbor == prevNode)\n                continue;\n            if (!visited[neighbor])\n                dfs(visited, rank, curNode, neighbor, curRank + 1);\n            rank[curNode] = Math.min(rank[curNode], rank[neighbor]);\n            if (rank[neighbor] == curRank + 1){\n                res.add(Arrays.asList(curNode, neighbor));\n            }\n        }\n    }\n}\n```
['Java']