[JAVA] Clean and Detailed Solution with Handwritten Explanation
Time Complexity - O(V + E)\nRuntime - 166ms - Faster than 58.96%\n\nclass Solution {\n    List<List<Integer>> ans;\n\tint count = 1;\n\n    public List<List<Int
Time Complexity - O(V + E)\nRuntime - 166ms - Faster than 58.96%\n```\nclass Solution {\n    List<List<Integer>> ans;\n\tint count = 1;\n\n    public List<List<Integer>> criticalConnections(int n, List<List<Integer>> connections) {\n        ans = new ArrayList<>();\n        List<List<Integer>> edge = new ArrayList<>();\n\t\tfor(int i = 1; i <= n; i++) {\n\t\t\tedge.add(new ArrayList<>());\n\t\t}\n\t\tfor(int i = 0; i < connections.size(); i++){\n\t\t\tint u = connections.get(i).get(0);\n\t\t\tint v = connections.get(i).get(1);\n\t\t\tedge.get(u).add(v);\n\t\t\tedge.get(v).add(u);\n\t\t}\n        \n        int[] par = new int[n];\n\t\tpar[0] = -1;\n\t\tint[] disc = new int[n];\n\t\tint[] low = new int[n];\n\t\t\n\t\tboolean[] vis = new boolean[n];\n\t\tdfs(0, edge, vis, par, disc, low);\n        \n        return ans;\n    }\n    \n    public void dfs(int n, List<List<Integer>> edge, boolean[] vis, int[] par, int[] disc, int[] low) {\n\t\tvis[n] = true;\n\t\tdisc[n] = count;\n\t\tlow[n] = count;\n\t\tcount++;\n\t\t\n\t\tfor(int nbr : edge.get(n)) {\n\t\t\tif(par[n] == nbr)\n\t\t\t\tcontinue;\n\t\t\telse if(vis[nbr] == true)\n\t\t\t\tlow[n] = Math.min(low[n], disc[nbr]);\n\t\t\telse {\n\t\t\t\tpar[nbr] = n;\n\t\t\t\tdfs(nbr, edge, vis, par, disc, low);\n\t\t\t\tlow[n] = Math.min(low[n], low[nbr]);\n\t\t\t\tif(low[nbr] > disc[n]) {\n                    List<Integer> toadd = new ArrayList<>();\n                    toadd.add(n);\n                    toadd.add(nbr);\n                    ans.add(toadd);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n```\n**Handwritten Notes**\n![image](https://assets.leetcode.com/users/images/ee0425c8-4c33-4ae1-adaf-f9d81d1a46b4_1642235073.5561364.jpeg)\n.\n![image](https://assets.leetcode.com/users/images/1945a09d-3202-43b4-8812-0d79e72fcda2_1642235091.4415748.jpeg)\n.\n![image](https://assets.leetcode.com/users/images/a4dd8ca2-2431-4f54-8397-e3a130ef5d5c_1642235099.6238954.jpeg)
['Java']