C++ || [Easy To understand] || [Union - Find]
Code\n\nstruct mycmp{\n     bool operator()(vector<int>&a , vector<int>&b){\n         if(a[2] < b[2]) return true;\n         else return false;\n     }\n};\ncla
# Code\n```\nstruct mycmp{\n     bool operator()(vector<int>&a , vector<int>&b){\n         if(a[2] < b[2]) return true;\n         else return false;\n     }\n};\nclass DSU{\n       vector<int> parent;\n       vector<int> rank;\n       public:\n       DSU(int n){\n           parent.resize(n);\n           rank.resize(n , 0);\n           for(int i = 0 ; i < n  ;i++)parent[i] = i;\n       }\n       int findPar(int node){\n           if(parent[node] == node)return node;\n           return parent[node] = findPar(parent[node]);\n       }\n       void UnionByRank(int u , int v){\n           int pu = findPar(u);\n           int pv = findPar(v);\n           if(pu == pv) return;\n\n           if(rank[pu] > rank[pv]){\n               parent[pv] = pu;\n           }else if(rank[pv] > rank[pu]){\n               parent[pu] = pv;\n           }else{\n               parent[pv] = pu;\n               rank[pu]++;\n           }\n       }\n};\nint MSTWeight(int n, vector<vector<int>> &edges){\n       DSU ds(n);\n       int result = 0;\n       for(int i = 0 ; i < edges.size() ; i++){\n              int u = edges[i][0];\n              int v = edges[i][1];\n              int wt = edges[i][2];\n\n              if(ds.findPar(u) == ds.findPar(v))continue;\n              result+=wt;\n              ds.UnionByRank(u , v);\n       }\n       return result;\n}\nint MSTWeightPseudoCritical(int n, vector<vector<int>> &edges , vector<int> &arr){\n       DSU ds(n);\n       int result = 0;\n       int pu = arr[0];\n       int pv = arr[1];\n       int wt = arr[2];\n       result+=wt;\n       ds.UnionByRank(pu , pv);\n       for(int i = 0 ; i < edges.size() ; i++){\n              int u = edges[i][0];\n              int v = edges[i][1];\n              int wt = edges[i][2];\n\n              if(ds.findPar(u) == ds.findPar(v))continue;\n              result+=wt;\n              ds.UnionByRank(u , v);\n       }\n       return result;\n}\nint MSTWeightCritical(int n, vector<vector<int>> &edges , vector<int> &arr){\n       DSU ds(n);\n       int result = 0;\n       int pu = arr[0];\n       int pv = arr[1];\n       for(int i = 0 ; i < edges.size() ; i++){\n              int u = edges[i][0];\n              int v = edges[i][1];\n              int wt = edges[i][2];\n              if(pu == u && pv == v)continue;\n              if(ds.findPar(u) == ds.findPar(v))continue;\n              result+=wt;\n              ds.UnionByRank(u , v);\n       }\n       for(int i = 0 ; i < n ; i++) {\n           if(ds.findPar(0) != ds.findPar(i)){\n               result = (int)1e9;\n               break;\n           }\n       }\n       return result;\n}\nclass Solution {\npublic:\n    vector<vector<int>> findCriticalAndPseudoCriticalEdges(int n, vector<vector<int>>& edges) {        \n         vector<vector<int>> temp = edges;\n         sort(temp.begin() , temp.end() , mycmp());\n         int mst = MSTWeight(n , temp);\n         vector<vector<int>> answer(2 , vector<int>());\n         \n         \n         for(int i = 0 ; i < edges.size() ; i++){\n               int number = MSTWeightCritical(n , temp , edges[i]);\n               if(number > mst){\n                   answer[0].push_back(i);\n                   continue;\n               }\n               number = MSTWeightPseudoCritical(n , temp , edges[i]);\n               if(number == mst){\n                   answer[1].push_back(i);\n               }\n         }\n         return answer;\n    }\n};\n```
['C++']