Hash Map Solution CPP 0(n)
Intuition-> First keep them in hash map respectively, to make search in constant time,
-> Now we will get the common element count and two variable for unique e
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
-> First keep them in hash map respectively, to make search in constant time,
-> Now we will get the common element count and two variable for unique element count from repective array against other array.
# Approach
<!-- Describe your approach to solving the problem. -->
-> Now count the elements for **ucount** as unique element that is present in array1 and common element from both array in **ccount**.
-> Now count the unique element from the array 2 against array 1.
-> Now the main logic, we will the count of the elememt to exact half of the arrat size if count value is greater than half, the reason we are doing because we need to take only half from the both array.
e.g. [1,2,3,4] and [5,6,7,8]
ucount1 = 4; half of it -> 2
ucount2 = 4; half of it -> 2;
->Now adding them will give the answer and obviously ccount will be zero.
-> Now we have ccount > 0 and other count varaible are also > 0 then we need to add all of it and check if we are not exceeding the actual array size, if yes return 'n'(the size of the array).

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(n)$$

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$$O(n)$$


# Code
```cpp []
class Solution {
public:
    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {
        int n = nums1.size();
        unordered_map<int,int> mp1;
        unordered_map<int,int> mp2;
        int ucount1 = 0;
        int ucount2 = 0;
        int ccount = 0;
        for(auto x: nums1) {
            mp1[x]++;
        }
        for(auto x: nums2) {
            mp2[x]++;
        }
        for(auto x: mp1){
            if(mp2.find(x.first) == mp2.end()){
                ucount1++;
            }else{
                ccount++;
            }
        }
        for(auto x: mp2) {
            if(mp1.find(x.first) == mp1.end()) {
                ucount2++;
            }
        }
        if(ucount1 > n/2){
            ucount1 = n/2;
        }
        if(ucount2 > n/2){
            ucount2 = n/2;
        }
        if(ucount1 + ccount + ucount2 > n){
            return n;
        }
        return ucount1 + ccount + ucount2;
    }
};
```
['C++']