C++ DSU Solution
Code\n\nclass DSU {\npublic:\n    vector<int> parent;\n    vector<int> size;\n\n    DSU(int n) {\n        parent.resize(n);\n        size.resize(n, 1);\n       
# Code\n```\nclass DSU {\npublic:\n    vector<int> parent;\n    vector<int> size;\n\n    DSU(int n) {\n        parent.resize(n);\n        size.resize(n, 1);\n        for (int i = 0; i < n; ++i) {\n            parent[i] = i;\n        }\n    }\n\n    int find(int u) {\n        if (parent[u] != u) {\n            parent[u] = find(parent[u]);\n        }\n        return parent[u];\n    }\n\n    void unionSets(int u, int v) {\n        int root_u = find(u);\n        int root_v = find(v);\n\n        if (root_u != root_v) {\n            if (size[root_u] < size[root_v]) {\n                std::swap(root_u, root_v);\n            }\n            parent[root_v] = root_u;\n            size[root_u] += size[root_v];\n        }\n    }\n};\nclass Solution {\npublic:\n    static bool comp(vector<int>& a , vector<int>& b){\n         return a[2]<b[2];\n    }\n    vector<vector<int>> findCriticalAndPseudoCriticalEdges(int n, vector<vector<int>>& edges) {\n        for(int i = 0 ; i<edges.size() ; i++){\n            edges[i].push_back(i);\n        }\n        sort(edges.begin(),edges.end(),comp);\n        DSU ds(n);\n        vector<int>ncr;\n        vector<int>cr;\n        int mst=0;\n        for(int i = 0 ; i<edges.size() ; i++){\n           if(ds.find(edges[i][0]) != ds.find(edges[i][1])){\n              ds.unionSets(edges[i][0] , edges[i][1]);\n              mst+=edges[i][2];\n           }\n        }\n\n        for(int i =0 ;i<edges.size() ;i++){\n\n            DSU dsu1(n);\n            int temp1 =0;\n            dsu1.unionSets(edges[i][0] , edges[i][1]);\n            temp1+=edges[i][2];\n            for(int j = 0 ;j<edges.size() ;j++){\n                if(i == j) continue;\n                if(dsu1.find(edges[j][0]) != dsu1.find(edges[j][1])){\n                   dsu1.unionSets(edges[j][0] , edges[j][1]);\n                   temp1+=edges[j][2];\n                }  \n            }\n\n            DSU dsu2(n);\n            int temp2 =0;\n            for(int j = 0 ;j<edges.size() ;j++){\n                if(i == j) continue;\n                if(dsu2.find(edges[j][0]) != dsu2.find(edges[j][1])){\n                   dsu2.unionSets(edges[j][0] , edges[j][1]);\n                   temp2+=edges[j][2];\n                }  \n            }\n            \n            bool fl1 = 0,fl2=0;\n            for(int i=0 ;i<n ;i++){\n                if(dsu1.size[i] == n){\n                    fl1=1;\n                }\n                if(dsu2.size[i] == n){\n                    fl2=1;\n                }\n            }\n            if(fl1 == 1 && fl2 == 1){\n                cout<<i<<"-"<<temp1<<"-"<<temp2<<"-"<<mst<<"   ";\n                if((temp1 == temp2) && (temp1 == mst)){\n                       ncr.push_back(edges[i][3]);\n                }\n                else if(temp1 == mst && temp2>=mst) {\n                      cr.push_back(edges[i][3]);\n                }\n            }\n            else if(fl1 == 1 && temp1 == mst){\n                   cr.push_back(edges[i][3]);\n            }\n        }\n        return {cr,ncr};\n    }\n};\n```
['C++']