Easy C++ solution || Using Union Find Method
\nclass Solution\n{\npublic:\n    class dsu{\n        public:\n        vector<int> parent, sz;\n        dsu(int n){\n            parent.resize(n);\n            
```\nclass Solution\n{\npublic:\n    class dsu{\n        public:\n        vector<int> parent, sz;\n        dsu(int n){\n            parent.resize(n);\n            sz.resize(n);\n            for(int i = 0; i<n; i++){\n                parent[i] = i;\n                sz[i] = 1;\n            }\n        }\n\n        int find_set(int x){\n            if(parent[x] == x) return x;\n            return parent[x] = find_set(parent[x]);\n        }\n\n        bool make_union(int x, int y){\n            int a = find_set(x);\n            int b = find_set(y);\n            if(a == b) return false;\n            if(sz[a] < sz[b]) swap(a, b);\n            parent[b] = a;\n            sz[a] += sz[b];\n            return true;\n        }\n\n        int count(int x){\n            return sz[x];\n        }\n    };\n    int maxNumEdgesToRemove(int n, vector<vector<int>> &edges)\n    {\n         vector<pair<int,int>> alice, bob, both;\n         for(int i = 0; i<edges.size(); i++){\n             int t = edges[i][0];\n             int x = edges[i][1]-1;\n             int y = edges[i][2]-1;\n             if(t == 3){\n                 both.push_back({x, y});\n             }\n             else if(t == 2){\n                 bob.push_back({x, y});\n             }\n             else{\n                 alice.push_back({x, y});\n             }\n         }\n\n         dsu a(n), b(n);\n         int ans = 0;\n         for(auto it : both){\n             ans += a.make_union(it.first, it.second);\n             b.make_union(it.first, it.second);\n         }\n         for (auto it : alice){\n             ans += a.make_union(it.first, it.second); \n         }\n         for (auto it : bob){\n             ans += b.make_union(it.first, it.second);     \n         }\n         if(a.count(a.find_set(0)) < n || b.count(b.find_set(0)) < n) return -1;\n         return edges.size() - ans;\n    }\n};\n```
['Union Find', 'C', 'C++']