Easy solution C++
IntuitionA set contains unique entries.1)So, why don't we first remove all the duplicate entries, keeping at least only one entry of that element.Now, if the re
# Intuition
A set contains unique entries. 
1)So, why don't we first remove all the duplicate entries, keeping at least only one entry of that element.
Now, if the required size (n) is achieved, the job is done. 
2)Otherwise, we still need to remove elements from the arrays(either from one or from the other or from both of them). For that matter, why don't we remove all the entries that are duplicate in these arrays, first keeping the at least one of the duplicate entry in one of the array.
3)Now, even after doing the 2nd operation, still the required size is not achieved, then we are left with no option other than to remove the unqiue entry, from either of the array.
Now, since all the duplicate entries that are present in the entire combnation considering 1 and 2 together, are removed, we are left with only unique elements.
So, now remove the unique entries up until our target is achieved. 

# Approach
1)First, we put both the array elements in a set and in map mpp1 and mpp2.
2)Now we check, that weather first removing duplicate entries does our task or not.
  For that operation, we remove all the values of a no. up until  the  value for that particular key is just 1.
And if p1 has reached n/2 we break out of mpp1, loop
Same we do for p2
3) We check, weather after adding count, gives the required size or not. 
4)If it still does not, then we we have to remove some element from the set.
This is done, by finding out the required elements by sub the current total from the original set size.
# Complexity
- Time complexity:
O(N)
- Space complexity:
O(N+M)

# Code
```cpp []
class Solution {
public:
    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) 
    {
       unordered_set<int>st;
        unordered_set<int>mpp1, mpp2;
        int n = nums1.size();
        for(int i = 0; i<n; ++i)
        {
            st.insert(nums1[i]);
            st.insert(nums2[i]);
            mpp1.insert(nums1[i]);
            mpp2.insert(nums2[i]);
        }
        int p1 = 0, p2 = 0;
        int m = n/2;
        int r1 = n - mpp1.size();
        int r2 = n - mpp2.size();
        if(r1 > m)
        {
            p1 = m;
        }
        else
        {
            p1 = r1;
        }
        if(r2 > m)
        {
            p2 = m;
        }
        else
        {
            p2 = r2;
        }
        if(p1 + p2 == n)
        {
            int s = st.size();
            st.clear();
            mpp1.clear();
            mpp2.clear();
            return s;
        }
        else
        {
            int o = st.size();
            int sub = 0; 
            int s = 0;
            for(auto it: st)
            {
                if(mpp1.find(it) != mpp1.end() && mpp2.find(it) != mpp2.end())
                {
                    s++;
                }
            }
            st.clear();
            mpp1.clear();
            mpp2.clear();
            int val = p1 + p2;
            if(val + s < n)
            {
                sub = n - (val + s);
            }
            return o - sub;
    }
};
```
['C++']