It was Union Find all along 😂 | Python 3
Please UpvoteCode
# Please Upvote

# Code
```python3 []
class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n)]
        self.rank = [1]*n
    def find(self,i):
        while i!=self.par[i]:
            self.par[i] = self.par[self.par[i]]
            i = self.par[i]
        return i
    def union(self, i, j):
        root_i = self.find(i)
        root_j = self.find(j)
        if root_i == root_j:
            return False
        # Union by size (or rank)
        if self.rank[root_i] > self.rank[root_j]:
            self.par[root_j] = root_i
            self.rank[root_i] += self.rank[root_j]
        else:
            self.par[root_i] = root_j
            self.rank[root_j] += self.rank[root_i]
        return True
class Solution:
    def findCriticalAndPseudoCriticalEdges(self, n: int, edges: List[List[int]]) -> List[List[int]]:
        for i, e in enumerate(edges):
            e.append(i) # [v1,v2,weight,original_index]
        edges.sort(key = lambda x:x[2])
        mst_weight = 0
        uf = UnionFind(n)
        for v1, v2, w, i in edges:
            if uf.union(v1,v2):
                mst_weight+=w
        
        critical, pseudo = [], []

        for n1,n2,e_weight,i in edges:
            weight = 0
            uf = UnionFind(n)
            for v1, v2, w, j in edges:
                if i!=j and uf.union(v1,v2):
                    weight+=w
            if max(uf.rank)!=n or  weight > mst_weight:
                critical.append(i)
                continue
            

            uf = UnionFind(n)
            uf.union(n1,n2)
            weight = e_weight
            for v1, v2, w, j in edges:
                if uf.union(v1,v2):
                    weight+=w
            if weight==mst_weight:
                pseudo.append(i)

        return [critical, pseudo]

```
['Python3']