[Java] Simple Solution based on finding MST
First, we find the cost of the MST using all edges.\n\nAn edge is critical iff all MSTs without this edge will have larger costs than the min cost. An edge is p
First, we find the cost of the MST using all edges.\n\nAn edge is critical iff all MSTs without this edge will have larger costs than the min cost. An edge is pseudo-critical if no matter we use  or do not use this edge, we can always find an MST with the min cost.\n\n```\nclass UnionFind{\n    final int[] parents;\n    int count;\n    \n    public UnionFind(int n){\n        this.parents = new int[n];\n        reset();\n    }\n    \n    public void reset(){\n        for(int i =0;i<parents.length;i++){\n            parents[i] = i;\n        }\n        count = parents.length;\n    }\n    \n    public int find(int i){\n        int parent = parents[i];\n        if(parent == i){\n            return i;\n        }else{\n            int root = find(parent);\n            parents[i] = root;\n            return root;\n        }\n    }\n    \n    public boolean union(int i, int j){\n        int r1 = find(i);\n        int r2 = find(j);\n        if(r1 != r2){\n            count--;\n            parents[r1] = r2;\n            return true;\n        }else{\n            return false;\n        }\n    }\n    \n}\n\nclass Solution {\n    public List<List<Integer>> findCriticalAndPseudoCriticalEdges(int n, int[][] edges) {\n       \n        List<Integer>criticals = new ArrayList<>();\n        List<Integer> pseduos = new ArrayList<>();\n        \n        Map<int[], Integer> map = new HashMap<>();\n        for(int i =0;i<edges.length;i++){\n            map.put(edges[i], i);\n        }\n        \n        Arrays.sort(edges, (e1, e2)->Integer.compare(e1[2], e2[2]));\n        int minCost = buildMST(n, edges, null, null);\n        \n        for(int i =0;i<edges.length;i++){\n            int[] edge = edges[i];\n            int index = map.get(edge);\n            int costWithout = buildMST(n, edges, null, edge);\n            if(costWithout > minCost){\n                criticals.add(index);\n            }else{\n                int costWith = buildMST(n, edges, edge, null);\n                if(costWith == minCost){\n                    pseduos.add(index);\n                }\n            }\n            \n        }\n        \n        return Arrays.asList(criticals, pseduos);\n    }\n    \n    private int buildMST(int n, int[][] edges, int[] pick, int[] skip){\n        UnionFind uf = new UnionFind(n);\n        int cost = 0;\n        if(pick != null){\n            uf.union(pick[0], pick[1]);\n            cost += pick[2];\n        }\n        \n        for(int[] edge : edges){\n            if(edge != skip && uf.union(edge[0], edge[1])){\n                cost += edge[2];\n            }\n        }\n        return uf.count == 1? cost : Integer.MAX_VALUE;\n    }\n}\n```
[]