Java solution
\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        int i,j,n=nums1.length;\n        Set<Integer> set1=new HashSet<>();\n    
```\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        int i,j,n=nums1.length;\n        Set<Integer> set1=new HashSet<>();\n        Set<Integer> set2=new HashSet<>();\n        Set<Integer> set3=new HashSet<>();\n        for(int x:nums1)\n        {\n            set1.add(x);\n            set3.add(x);\n        }\n        for(int x:nums2)\n        {\n            set2.add(x);\n            set3.add(x);\n        }\n        int common=set1.size()+set2.size()-set3.size();\n        int n1=set1.size(),n2=set2.size();\n        int ans=Math.min(n/2,n1-common);\n        ans+=Math.min(n/2,n2-common);\n        ans+=common;\n        ans=Math.min(n,ans);\n        return ans;\n    }\n}\n```
['Java']