C++ | Intuitive solution
Intuition\nVenn Diagram\n\n# Approach\nCalculate no. of same and different elements\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\n Add your 
# Intuition\nVenn Diagram\n\n# Approach\nCalculate no. of same and different elements\n\n# Complexity\n- Time complexity:\nO(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        set<int> st1, st2;\n        for(auto x : nums1) st1.insert(x);\n        for(auto x : nums2) st2.insert(x);\n\n        int same = 0;\n        unordered_map<int, int> mp;\n        for(auto it : st1) {\n            if(st2.find(it) != st2.end()) {\n                mp[it]++;\n                same++;\n            }\n        }\n\n        int left = n - same;\n        if(left <= 0) return same;\n\n        int d1 = 0, d2 = 0;\n        for(auto it : st1) {\n            if(mp.find(it) == mp.end()) d1++;\n        }\n        for(auto it : st2) {\n            if(mp.find(it) == mp.end()) d2++;\n        }\n\n        int p1 = min(d1, n / 2);\n        int p2 = min(d2, n / 2);\n\n        if(p1 >= n / 2 && p2 >= n / 2) {\n            return (p1 + p2);\n        } else if (p1 >= n / 2) {\n            return (p1 + p2 + min(same, (n / 2) - p2));\n        } else if (p2 >= n / 2) {\n            return (p1 + p2 + min(same, (n / 2) - p1));\n        }\n        return (p1 + p2 + min(same, n - (p1 + p2)));\n    }\n};\n```
['C++']