[JAVA] Following the LC hints :)
I will be honest, getting intution of this question is little bit tricky (atleast for me), but once you get the idea from hints, writing the code is pretty stra
I will be honest, getting intution of this question is little bit tricky (atleast for me), but once you get the idea from hints, writing the code is pretty straight forward, anyways here\'s the implementation, happy leetcoding!\n\n```\nclass Solution {\n    public List<List<Integer>> findCriticalAndPseudoCriticalEdges(int n, int[][] edges) {\n        List<Integer> critical = new ArrayList<>();\n        List<Integer> pseudo = new ArrayList<>();\n        List<List<Integer>> ans = new ArrayList<>();\n        int len = edges.length;\n        \n        Map<int[], Integer> index = new HashMap<>();\n        for (int i = 0; i < len; i++) {\n            int[] edge = edges[i];\n            index.put(edge, i);\n        }\n        \n        int msp = 0;\n        Arrays.sort(edges, (a, b) -> a[2] - b[2]);\n        DSU main = new DSU(n);\n        int count = 0;\n        \n        int i = 0;\n        while(i < edges.length && count < n) {\n            int[] edge = edges[i];\n            if (main.union(edge[0], edge[1]) == true) {\n                count++;\n                msp += edge[2];\n            }\n            i++;\n        }\n        \n        System.out.println(msp);\n        \n        for (i = 0; i < len; i++) {\n            int[] cur = edges[i];\n            int curIndex = index.get(cur);\n            DSU dsu = new DSU(n);\n            DSU include = new DSU(n);\n            int cost = 0, includeCost = cur[2];\n            include.union(cur[0], cur[1]);\n \n            for (int j = 0; j < len; j++) {\n                if (i == j) continue;\n                int[] edge = edges[j];\n                if (dsu.union(edge[0], edge[1]) == true) {\n                    cost += edge[2];\n                }\n                if (include.union(edge[0], edge[1]) == true) {\n                    includeCost += edge[2];\n                }\n            }\n            if (cost != msp) critical.add(curIndex);\n            else if (includeCost == msp) pseudo.add(curIndex);\n        }\n        \n        ans.add(critical); ans.add(pseudo);\n        return ans;\n    }\n    \n    class DSU {\n        int[] root;\n        int[] rank;\n        \n        public DSU (int n) {\n            this.root = new int[n];\n            this.rank = new int[n];\n            \n            for (int i = 0; i < n; i++) {\n                root[i] = i;\n                rank[i] = 1;\n            }\n        }\n        \n        public int find(int x) {\n            if (root[x] == x) return x;\n            return root[x] = find(root[x]);\n        }\n        \n        public boolean union(int x, int y) {\n            int rootX = find(x);\n            int rootY = find(y);\n            \n            if (rootX == rootY) return false;\n            \n            if (rank[rootX] > rank[rootY]) {\n                root[rootY] = rootX;\n                rank[rootX] += rank[rootY];\n                \n            } else {\n                root[rootX] = rootY;\n                rank[rootY] += rank[rootX];\n            }\n            \n            return true;\n        }\n    }\n}\n```
[]