Intuition Based Solution || Diff to understand || Clean Code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nBrute Force approach.\n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBrute Force approach.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(NlogN)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n# Code\n```\nclass Solution {\npublic:\n    int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n        int n= nums1.size();\n        set<int> nums11;\n\n        for(int i:nums1) nums11.insert(i);\n\n        set<int> nums22;\n\n        for(int i: nums2) nums22.insert(i);\n    \n        \n        nums1.clear();\n        nums2.clear();\n\n        for(auto it: nums11) nums1.push_back(it);\n        for(auto it: nums22) nums2.push_back(it);\n\n        sort(nums1.begin(),nums1.end());\n        sort(nums2.begin(),nums2.end());\n\n        int i=0,j=0;\n        int count=0;\n\n        while(i<nums1.size() && j<nums2.size()){\n            if(nums1[i]==nums2[j]) {\n                count++;\n                i++;\n                j++;\n            }\n\n            else if(nums1[i]>nums2[j]) j++;\n            else i++;\n        }\n        int one,two;\n        \n        if(nums1.size()>=nums2.size()){\n            one = nums1.size()-count;\n           if(one>n/2) one =n/2;\n           two = nums2.size();\n          \n\n        }\n        else {\n            one = nums1.size();\n          \n            two = nums2.size()-count;\n            if(two>n/2) two =n/2;\n        }\n\n        return one+two>n ? n : one + two;\n\n    }\n};\n```
['Sorting', 'Ordered Set', 'C++']