Easy Sorting + Hashmaps
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```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        int n = nums1.size();\n        sort(begin(nums1),end(nums1));\n        sort(begin(nums2),end(nums2));\n        int r1 = 0, r2 = 0;\n        for(int i=1;i<n;i++){\n            if(r1 == n/2) break;\n            if(nums1[i] == nums1[i-1]){\n                nums1[i-1] = 0;\n                r1++;\n            }\n        }\n        for(int i=1;i<n;i++){\n            if(r2 == n/2) break;\n            if(nums2[i] == nums2[i-1]){\n                nums2[i-1] = 0;\n                r2++;\n            }\n        }\n        unordered_map<int,int> mp;\n        for(auto i:nums1){\n           if(i != 0) mp[i]++;\n        }\n        for(auto i:nums2){\n            if(i != 0) mp[i]++;\n        }\n        if(r1 >= n/2 and r2 >= n/2) return mp.size();\n            int req1 = n/2 - r1;\n            int req2 = n/2 - r2;\n            req1 = max(req1,0);\n            req2 = max(req2,0);\n            cout<<req1 <<" "<<req2<<endl;\n            if(req1 > 0){\n                for(auto i:nums1){\n                    if(req1 == 0) break;\n                    if(i != 0){\n                        if(mp[i] > 1){\n                            req1--;\n                            mp[i]--;\n                        }\n                    }\n                }\n            }\n            if(req2 > 0){\n                for(auto i:nums2){\n                    if(req2 == 0) break;\n                    if(i != 0){\n                        if(mp[i] > 1){\n                            req2--;\n                            mp[i]--;\n                        }\n                    }\n                }\n            }\n            cout<<req1<<" "<<req2<<endl;\n            int ans = mp.size();\n            ans -= (req1 + req2);\n            return ans;\n    }\n};\n```
['C++']