Easy to understand with approach and by using map
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1-Determine Target Size count1 and count2 which is nums1.size()/2.\n\n2-C
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n**1-Determine Target Size count1 and count2 which is nums1.size()/2.**\n\n**2-Count Occurrences of elements in nums1 and nums2**\n\n**3-Prioritize Arrays: which is having more unique elements.**\nCheck if the size of mp1 is greater than or equal to the size of mp2.\n\n4-**Create a set (st) to store unique elements**.\n\n5-**Iterate through nums1 and insert unique elements into the set until the target size (count1) is reached.**\n**Exclude elements already present in st and those found in nums2 (mp2)**.\n\n6-**If the target size (count1) is not reached then(count2 += count1), add remaining unique elements from nums2 to the set according to count2**.\n\n7-**Repeat steps 4-6 with the roles of nums1 and nums2 swapped**.\n\n**Return the size of the final set obtained from the array with more unique elements.**\n\n\n# Complexity\n- Time complexity: O(m + n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(min(m, n))\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        int count1 = nums1.size()/2;\n        int count2 = nums2.size()/2;\n        unordered_map<int,int>mp2;\n        for(int i =0;i<nums2.size();i++) mp2[nums2[i]]++;\n        unordered_map<int,int>mp1;\n        for(int i =0;i<nums1.size();i++) mp1[nums1[i]]++;\n      \n        if(mp1.size()>=mp2.size()){\n          set<int> st;\n          for(int i = 0;i<nums1.size();i++){\n            if(st.find(nums1[i])==st.end() && count1>0 && mp2.find(nums1[i])==mp2.end()){\n              st.insert(nums1[i]);  \n              count1--;\n            }\n          }\n          if(count1 != 0) count2 += count1;\n          for(int i = 0;i<nums2.size();i++){\n            if(st.find(nums2[i])==st.end() && count2>0){\n              st.insert(nums2[i]);\n              count2--;\n            }\n          }\n          return st.size();\n        }\n      else{\n       set<int> st;\n        for(int i = 0;i<nums2.size();i++){\n          if(st.find(nums2[i])==st.end() && count2>0 && mp1.find(nums2[i])==mp1.end()){\n            st.insert(nums2[i]);\n            count2--;\n          }\n        }\n        if(count2 != 0) count1 += count2;\n        for(int i = 0;i<nums1.size();i++){\n          if(st.find(nums1[i])==st.end() && count1>0){\n            st.insert(nums1[i]);\n            count1--;\n          }\n        }\n        for(auto it: st){\n          cout<<it<<" ";\n        }\n        return st.size();\n      }\n        \n    }\n};\n```
['Ordered Set', 'C++']