C++ Implementation using Set
\n\n# Code\n\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        vector<int>v,v1;\n        sort(nums1.begin(),
\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        vector<int>v,v1;\n        sort(nums1.begin(),nums1.end());\n        \n        sort(nums2.begin(),nums2.end());\n        for(auto x:nums1){\n            if(v.empty()){\n                v.push_back(x);\n            }\n            else if(v.back()!=x){\n                v.push_back(x);\n            }\n        }\n        for(auto x:nums2){\n            if(v1.empty()){\n                v1.push_back(x);\n            }\n            else if(v1.back()!=x){\n                v1.push_back(x);\n            }\n        }\n        \n        set<int>st(nums1.begin(),nums1.end());\n        set<int>st2(nums2.begin(),nums2.end());\n        int i=0,j=0,n=nums1.size()/2,m=nums2.size()/2;\n        set<int>s;\n        \n        for(auto x:v)\n        {\n            if(st2.find(x)==st2.end()){\n                i++;\n                s.insert(x);\n                st.erase(x);\n            }\n            if(i==n)\n            {\n                break;\n            }\n        }\n        for(auto x:v1)\n        {\n            if(st.find(x)==st.end()){\n                j++;\n                // cout<<x<<" ";\n                s.insert(x);\n                st2.erase(x);\n            }\n            if(j==m){\n                break;\n            }\n        }\n        // cout<<i<<" "<<j<<endl;\n        while(i<n && j<m && st.size() && st2.size()){\n            if(*st.begin()==*st2.begin()){\n                if(n-i>m-j){\n                    i++;\n                    s.insert(*st.begin());\n                    st.erase(*st.begin());\n                    st2.erase(*st2.begin());\n                }\n                else{\n                    j++;\n                    s.insert(*st.begin());\n                    st.erase(*st.begin());\n                    st2.erase(*st2.begin());\n                }\n            }\n            else{\n                \n            }\n        }\n        while(i<n && st.size()){\n            \n            if(s.find(*st.begin())==s.end())\n               i++,s.insert(*st.begin()), st.erase(*st.begin());\n            else\n                st.erase(*st.begin());\n        }\n        while(j<m && st2.size()){\n            \n            if(s.find(*st2.begin())==s.end())\n               j++,s.insert(*st2.begin()), st2.erase(*st2.begin());\n            else\n                st2.erase(*st2.begin());\n        }\n        return i+j;\n    }\n};\n```
['Hash Table', 'C++']