3 Set solution
Code\n\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        int n = nums1.size();\n        set<int> s1;\n      
# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        int n = nums1.size();\n        set<int> s1;\n        set<int> s2;\n        set<int> s3;\n        for(int i=0; i<n; i++){\n            s1.insert(nums1[i]);\n            s2.insert(nums2[i]);\n        }\n\n        merge(s1.begin(), s1.end(), s2.begin(), s2.end(), inserter(s3, s3.begin()));\n        int x = s1.size();\n        int y = s2.size();\n        int z = s3.size();\n\n        int intersection = x + y - z;\n        int a = max(0, x-intersection);\n        int b = max(0, y-intersection);\n\n        int i = min(a, n/2);\n        int j = min(b, n/2);\n        int k = min(intersection, n-(i+j));\n        return i + j + k;\n    }\n};\n```
['Ordered Set', 'C++']