100% Solution using HashSet O(n+m)
Complexity\n- Time complexity: O(n+m)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n+m)\n Add your space complexity here, e.g. O(n) \n\n
# Complexity\n- Time complexity: $$O(n+m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n+m)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        Set<Integer> set1 = new HashSet<>();\n        Set<Integer> set2 = new HashSet<>();\n        Set<Integer> set3 = new HashSet<>();\n        int ans=0;\n        for(int i:nums1){\n            set1.add(i);\n            set3.add(i);\n        }\n        if(set1.size()>nums1.length/2)\n            ans=nums1.length/2;\n        else\n            ans=set1.size();\n        for(int i:nums2){\n            set2.add(i);\n            set3.add(i);\n        }    \n        if(set2.size()>nums2.length/2)\n            ans+=nums2.length/2;\n        else\n            ans+=set2.size(); \n        return ans>set3.size() ? set3.size() : ans;       \n    }\n}\n```
['Java']