C++||Union Find|| Easy to Understand
```\nclass Solution {\npublic:\n    int find(vector &par,int u)\n    {\n        if(u==par[u])\n            return u;\n        return par[u]=find(par,par[u]);\n 
```\nclass Solution {\npublic:\n    int find(vector<int> &par,int u)\n    {\n        if(u==par[u])\n            return u;\n        return par[u]=find(par,par[u]);\n    }\n    void unions(vector<int> &par,int u,int v)\n    {\n        int pu=find(par,u);\n        int pv=find(par,v);\n        par[pu]=pv;\n    }\n    int maxNumEdgesToRemove(int n, vector<vector<int>>& edges)\n    {\n        vector<int> a(n+1),b(n+1);\n        int ans=0;\n        for(int i=0;i<=n;i++)\n        {\n            a[i]=i;\n            b[i]=i;\n        }\n        for(auto &e:edges)\n        {\n            if(e[0]!=3)\n                continue;\n            if(find(a,e[1])==find(a,e[2]))\n            {\n                ans++;\n                continue;\n            }\n            unions(a,e[1],e[2]);\n            unions(b,e[1],e[2]);\n        }\n        for(auto &e:edges)\n        {\n            int u=e[1],v=e[2];\n            if(e[0]==1)\n            {\n                if(find(a,u)==find(a,v))\n                {\n                    ans++;\n                }\n                else\n                {\n                    unions(a,u,v);\n                }\n            }\n            else if(e[0]==2)\n            {\n                if(find(b,u)==find(b,v))\n                {\n                    ans++;\n                }\n                else\n                {\n                    unions(b,u,v);\n                }\n            }\n        }\n        for(int i=1;i<=n;i++)\n        {\n            if(find(a,i)!=find(a,n)||find(b,i)!=find(b,n))\n            {\n                return -1;\n            }\n        }\n        return ans;\n        \n    }\n};\n// if you like the solution plz upvote.
['Union Find', 'C']