C++ | Easy beginner friendly sol | Deatailed explanation with comment | Set
 # Intuition  \n\n\n\n\n\n# Complexity\n- Time complexity: O(n)  [Insert operation in unordered set takes O(1) time on avg.]\n\n\n- Space complexity: O(n) [To s
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$  [Insert operation in unordered set takes $$O(1)$$ time on avg.]\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$ [To store elements in set]\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        unordered_set<int> s1, s2, u;\n        //s1 = set(nums1)  and  s2 = set(nums2)\n        //u= s1 union s2\n\n        int n = nums1.size() / 2;   // number of elements to be choosen from each array\n        for(auto x:nums1){\n            s1.insert(x);\n            u.insert(x);\n        }\n        for(auto x:nums2){\n            s2.insert(x);\n            u.insert(x);\n        }\n        int common = s1.size() + s2.size() - u.size();   // size of s1 intersection s2\n        int n1 = s1.size();\n        int n2 = s2.size();\n\n        int ans = 0;\n        ans += min(n, n1-common);   // take all elements from s1-s2  [maximum n elements]\n        ans += min(n, n2-common);   // take all elements from s2-s1\n        ans += common;              // now take common elements\n        ans = min(ans, n * 2);      // if nukber of elements taken are more than 2*n make the answer 2*n\n        return ans;\n    }\n};\n```
['C++']