💡Most Optimized and Intuitive Code💡
Code\n\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<int>s1,s2,combined;\n        int n = 
# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<int>s1,s2,combined;\n        int n = nums1.size();\n        for(auto it : nums1) s1.insert(it);\n        for(auto it : nums2) s2.insert(it);\n        for(auto it : s1) combined.insert(it);\n        for(auto it : s2) combined.insert(it);\n        int a,b; // a,b = maximum no. of elements from first and second set  \n      \n        if(s1.size()< n/2) a = s1.size(); // if the size of set is less than the maximum elements we can take\n        else a = n/2;                     // else take all n/2 elements i.e. atleast n/2 elements are distinct\n        \n        if(s2.size() < n/2) b = s2.size();\n        else b = n/2;\n        int combined_size = combined.size();\n     \n        return min(combined_size,a+b); \n       // min - as from a+b same elements from both the sets could be calculated\n       // ans.size() to consider the possibility of repeated elements in both the sets\n    }\n};\n```\n# Kindly Upvote If you like the code \uD83D\uDE0A
['C++']