[C++] Greedy, Hash Tables
Complexity\n- Time complexity: O(n)\n- Space complexity: O(n)\n\n# Code\n\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nu
# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        int n = nums1.size();\n        unordered_set<int> s1, s2, join;\n        for (const auto& num : nums1) {\n            s1.insert(num);\n            join.insert(num);\n        }\n        for (const auto& num : nums2) {\n            s2.insert(num);\n            join.insert(num);\n        }\n        int unique1 = s1.size(), unique2 = s2.size(), unique_join = join.size();\n        return min(unique_join, min(unique1, n / 2) + min(unique2, n / 2));\n    }\n};\n```
['Array', 'Hash Table', 'Greedy', 'C++']