Easy CPP Solution
\n\n# Code\n\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) \n    {\n        set<int>st1(nums1.begin(),nums1.end());
\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) \n    {\n        set<int>st1(nums1.begin(),nums1.end());\n        set<int>st2(nums2.begin(),nums2.end());\n        int ans1=0;\n        int n=nums1.size();\n        for (auto it:nums1)\n        {\n            if (st1.find(it)!=st1.end() && st2.find(it)==st2.end())\n            {\n              ans1++;\n              st1.erase(it);\n              st2.erase(it);\n            }\n        }\n        if (ans1>n/2) ans1=n/2;\n        int ans2=0;\n        for (auto it:nums2)\n        {\n            if (st2.find(it)!=st2.end() && st1.find(it)==st1.end())\n            {\n              ans2++;\n              st2.erase(it);\n              st1.erase(it);\n            }\n        }\n        if (ans2>n/2) ans2=n/2;\n        if (ans1+ans2==n) return n;\n        int sz=st1.size();\n        return min(ans1+ans2+sz,n);\n\n    }\n};\n```
['C++']