CONDITION BASED || C++
Code\n\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_map<int,int> mp1,mp2;\n        unordered_
# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_map<int,int> mp1,mp2;\n        unordered_set<int> s;\n        for(auto &i: nums1){\n            mp1[i]++;\n        }\n        for(auto &i: nums2){\n            mp2[i]++;\n        }\n        int a = 0, b = 0,c=0,n=nums1.size(),x;\n        for(auto &i: mp1){\n            a += (i.second-1);\n        }for(auto &i: mp2){\n            b += (i.second-1);\n        }for(auto &i: mp1){\n            if(mp2.count(i.first)){\n                c++;\n            }\n        }\n        if(a==0&&b==0&&c==0)return min(n,2*n-c);\n        if(a>=n/2&&b>=n/2){\n            return 2*n-a-b-c;\n        }else if(a>=n/2 && b<n/2){\n            if(b+c>=n/2)return 2*n-a-b-c;\n            else return 2*n-a-n/2;\n        }else if(a<n/2 && b>=n/2){\n            if(a+c>=n/2)return 2*n-a-b-c;\n            else return 2*n-b-n/2;\n        }\n        if(a+b+c>=n)return 2*n-a-b-c;\n        if(a<=n/2){\n            x = n/2-a;\n            a += min(x,c);\n            c = min(0,c-x);\n        }\n        if(b<=n/2&&c>0){\n            x = n/2-b;\n            b += min(x,c);\n            c = min(0,c-x);\n        }\n        return min(2*n-a-b-c,n);\n    }\n};\n```
['C++']