✅🔥Easy & simple C++ solution with line by line explanation🔥✅
Intuition\nNeed to remove n/2 elements from both nums1 and nums2 such that when we combine both then the elements will be maximum.\n\n---\n\n# Approach\n- First
# Intuition\nNeed to remove n/2 elements from both nums1 and nums2 such that when we combine both then the elements will be maximum.\n\n---\n\n# Approach\n- First make a set and store the elements of num1 in the set and take its size.\n- Then clear that set and perform same thing with nums2.\n- Then again clear the set and now store both nums1 and nums2 in the set and store in another variable as size3.\n- Now take the min of size3, min(n/2, size1)+min(n/2, size2).\n\n---\n\n# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(n)$$\n\n---\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<int> s;\n        int n = nums1.size();\n        for(int i = 0 ; i < n ; i++) s.insert(nums1[i]);\n        int size1 = s.size();\n        s.clear();\n        for(int i = 0 ; i < n ; i++) s.insert(nums2[i]);\n        int size2 = s.size();\n        s.clear();\n        for(int i = 0 ; i < n ; i++){\n            s.insert(nums1[i]);\n            s.insert(nums2[i]);\n        }\n        int size3 = s.size();\n        return min(size3, min(n/2, size1)+min(n/2, size2));\n    }\n};\n```
['Array', 'Hash Table', 'Greedy', 'C', 'C++']