🔥🔥🔥C++ | super easy | clean code | MST | fully optimized | beats 100% solution🔥🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\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```\nstruct DSU{\n    int parent[101];\n    int size[101];\n    DSU(int n){\n        for(int i=0; i<n; i++){\n            parent[i] = i;\n            size[i] = 1;\n        }\n    }\n    int findParent(int node){\n        if(parent[node] == node) return node;\n        return parent[node] = findParent(parent[node]);\n    }\n    bool unionBySize(int u, int v){\n        int pu = findParent(u);\n        int pv = findParent(v);\n        if(pu == pv) return false;\n\n        if(size[pu] < size[pv]){\n            parent[pu] = pv;\n            size[pv] += size[pu];\n        }\n        else{\n            parent[pv] = pu;\n            size[pu] += size[pv];\n        }\n        return true;\n    }\n};\nint sz;\nclass Solution {\nprivate:\n    int kruskal(vector<vector<int>>& edges, int n, int skip, int pick){\n        DSU dsu(n);\n        int sum = 0;\n\n        if(pick > -1){\n            dsu.unionBySize(edges[pick][0],edges[pick][1]);\n            sum += edges[pick][2];\n            n--;\n        }\n\n        for(int i=0; i<sz; i++){\n            if(skip == i) continue;\n            int u = edges[i][0];\n            int v = edges[i][1];\n\n            if(dsu.unionBySize(u,v)){\n                sum += edges[i][2];\n                n--;\n            }\n        }\n        \n        if(n == 1) return sum;\n        return 1e9;\n    }\npublic:\n    vector<vector<int>> findCriticalAndPseudoCriticalEdges(int n, vector<vector<int>>& edges) {\n        sz = edges.size();\n        for(int i=0; i<sz; i++){\n            edges[i].push_back(i);\n        }\n        auto comp = [&](vector<int>& a, vector<int>& b){\n            return a[2] < b[2];\n        };\n        sort(edges.begin(),edges.end(),comp);\n\n        int mst_wt = kruskal(edges,n,-1,-1);\n\n        vector<int> critical;\n        vector<int> pseudo;\n        for(int i=0; i<sz; i++){\n\n            if(kruskal(edges,n,i,-1) > mst_wt){\n                critical.push_back(edges[i][3]);\n            }\n            else if(kruskal(edges,n,-1,i) == mst_wt){\n                pseudo.push_back(edges[i][3]);\n            }\n        }\n\n        return {critical,pseudo};\n    }\n};\n```
['C++']