Java DFS solution - Tarjan's Algorithm
Recommened : Should know Tarjan\'s algorithm first\n\nclass Solution {\n    List<List<Integer>> result;\n    int time = 0;\n    \n    public List<List<Integer>>
**Recommened : Should know Tarjan\'s algorithm first**\n```\nclass Solution {\n    List<List<Integer>> result;\n    int time = 0;\n    \n    public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {\n        List<Integer>adj[] = new ArrayList[n];\n        for(int i = 0; i < n; i++)\n            adj[i] = new ArrayList<>();\n        \n        for(List<Integer> edge : connections){\n            int a = edge.get(0);\n            int b = edge.get(1);\n            \n            adj[a].add(b);\n            adj[b].add(a);\n        }\n        \n        int timestamp[] = new int[n];\n        boolean visited[] = new boolean[n];\n        result = new ArrayList<>();\n        dfs(adj, visited, timestamp, 0, -1);\n        return result;\n    }\n    \n    void dfs(List<Integer>[]adj, boolean[] visited, int[] timestamp, int vertex, int prev){\n        visited[vertex] = true;\n        timestamp[vertex] = time++;\n        int currentTimeStamp = timestamp[vertex];\n        \n        for(int v : adj[vertex]){\n            if(v == prev) continue;\n            \n            if(!visited[v])\n                dfs(adj, visited, timestamp, v, vertex);\n            timestamp[vertex] = Math.min(timestamp[vertex], timestamp[v]);\n            if(currentTimeStamp < timestamp[v])\n                result.add(Arrays.asList(vertex, v));\n        }\n    }\n}\n```
[]