C++ maps
\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_map<int, int> m1, m2;\n        for (int i = 0; 
```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_map<int, int> m1, m2;\n        for (int i = 0; i < nums1.size(); ++i)\n            ++m1[nums1[i]], ++m2[nums2[i]];\n        int n1 = nums1.size() / 2, n2 = n1;\n        for (auto& [f, s] : m1) n1 -= s - 1;\n        for (auto& [f, s] : m2) n2 -= s - 1;\n        int ans = 0;\n        for (auto& [f,s] : m1){\n            if (m2.count(f)){\n                m2.erase(f);\n                if (n1 > 0) --n1;\n                else --n2;\n            }\n            ++ans;\n        }\n        return ans + m2.size() - max(0, n1) - max(0, n2);\n    }\n};\n```
[]