Simple HashMaps and Set Solution
\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        HashMap<Integer,Integer> map1=new HashMap<>();\n        int n=nums1.lengt
```\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        HashMap<Integer,Integer> map1=new HashMap<>();\n        int n=nums1.length;\n        HashMap<Integer,Integer> map2=new HashMap<>();\n        Set set=new HashSet<>();\n        int ans=0;\n        for(int i=0;i<nums1.length;i++)\n        {\n            map1.put(nums1[i],map1.getOrDefault(nums1[i],0)+1);\n            set.add(nums1[i]);\n        }\n        for(int i=0;i<nums2.length;i++)\n        {\n            map2.put(nums2[i],map2.getOrDefault(nums2[i],0)+1);\n            set.add(nums2[i]);\n        }\n        if(map1.size()>=n/2) ans+=n/2;\n        else ans+=map1.size();\n        if(map2.size()>=n/2) ans+=n/2;\n        else ans+=map2.size();\n        if(set.size()>=ans)\n            return ans;\n        return set.size();\n    }\n}\n```\n\n\n
['Java']