🔥Easy Solution 🔥Python3/C/C#/C++/Java🔥Use MST algorihtm🔥With 🗺️Image🗺️
Intuition\nTo your preferred programming language\nyou can turn.\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexit
# Intuition\nTo your preferred programming language\nyou can turn.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass UnionFind:\n    def __init__ (self, n):\n        self.parents = list(range(n))\n        self.weight = 0\n        self.edgeCount = 0\n\n    def find(self, x):\n        if x != self.parents[x]:\n            self.parents[x] = self.find(self.parents[x])\n        return self.parents[x]\n\n    def union(self, x, y, w):\n        r1 = self.find(x)\n        r2 = self.find(y)\n\n        if r1 != r2:\n            self.parents[r2] = r1\n            self.weight += w\n            self.edgeCount += 1\n\nclass Solution:\n    def findCriticalAndPseudoCriticalEdges(self, n: int, edges: List[List[int]]) -> List[List[int]]:\n\n        edges = [(w,a,b,i) for i, (a,b,w) in enumerate(edges)]\n        edges.sort()\n\n        uf1 = UnionFind(n)\n        for w, a, b, _ in edges:\n            uf1.union(a, b, w)\n\n\n        minWeight = uf1.weight\n\n\n        ce = []\n        pce = []\n        m = len(edges)\n\n\n        for i in range(m):\n            uf2 = UnionFind(n)\n            for j in range(m):\n                if i == j:\n                    continue\n                w,a,b,_ = edges[j]\n                uf2.union(a,b,w)\n            \n            if uf2.weight > minWeight or uf2.edgeCount < n-1:\n                ce.append(edges[i][3])\n\n            else:\n                \n                uf3 = UnionFind(n)\n                w,a,b,_ = edges[i]\n                uf3.union(a,b,w)\n                for j in range(m):\n                    w,a,b,_ = edges[j]\n                    uf3.union(a,b,w)\n                \n                if uf3.weight == minWeight:\n                    pce.append(edges[i][3])\n        return ce, pce\n```
['C', 'C++', 'Java', 'Python3', 'C#']