Simplest Code|Greedy|C++
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:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n);\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        set<int>s1,s2,s;\n        int n=nums1.size();\n        for(int i=0;i<n;i++){\n            s1.insert(nums1[i]);\n            s2.insert(nums2[i]);\n        }\n        for(int it:s1)  if(s2.find(it)!=s2.end()&&s2.size()>n/2) s2.erase(it);\n        for(int it:s2) if(s1.find(it)!=s1.end()&&s1.size()>n/2) s1.erase(it);\n            \n        if(s1.size()<=n/2&&s2.size()<=n/2){\n            for(int it:s1) s.insert(it);\n            for(int it:s2) s.insert(it);\n            return s.size();\n        }\n        else if(s1.size()>n/2&&s2.size()<=n/2) return s2.size()+n/2;\n        else if(s1.size()<=n/2&&s2.size()>n/2) return s1.size()+n/2;\n        else return n;\n        return 0;\n    }\n};\n```
['Greedy', 'C++']