Simple Java Solution
Code\n\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        HashMap<Integer,Integer> h1=new HashMap<Integer,Integer>();\n      
# Code\n```\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        HashMap<Integer,Integer> h1=new HashMap<Integer,Integer>();\n        HashMap<Integer,Integer> h2=new HashMap<Integer,Integer>();\n        int count1=0,count2=0;\n        for(int i=0;i<nums1.length;i++)\n        {\n            if(!h1.containsKey(nums1[i]))\n            {\n                h1.put(nums1[i],1);\n            }\n            else\n            {\n                   if(count1<nums1.length/2)\n                   {\n                     count1++;\n                   }\n                   else\n                   {\n                        h1.put(nums1[i],h1.get(nums1[i])+1);\n                   }\n            }\n        }\n        for(int i=0;i<nums2.length;i++)\n        {\n            if(!h2.containsKey(nums2[i]))\n            {\n                h2.put(nums2[i],1);\n            }\n            else\n            {\n                   if(count2<nums2.length/2)\n                   {\n                     count2++;\n                   }\n                   else\n                   {\n                        h2.put(nums2[i],h2.get(nums2[i])+1);\n                   }\n            }\n        }\n        if(count1==nums1.length/2 && count2==nums2.length/2)\n        {\n            HashSet<Integer> hset=new HashSet<Integer>();\n            for(Map.Entry<Integer,Integer> entry:h1.entrySet())\n            {\n                hset.add(entry.getKey());\n            }\n            for(Map.Entry<Integer,Integer> entry:h2.entrySet())\n            {\n                hset.add(entry.getKey());\n            }\n\n            return hset.size();\n        }\n        else if(count1==nums1.length/2)\n        {\n            HashSet<Integer> hset=new HashSet<Integer>();\n            for(Map.Entry<Integer,Integer> entry:h1.entrySet())\n            {\n                hset.add(entry.getKey());\n            }\n            for(Map.Entry<Integer,Integer> entry:h2.entrySet())\n            {\n               int p=entry.getKey();\n               if(hset.contains(p))\n               {\n                    if(count2<nums2.length/2)\n                    {\n                    count2++;\n                    }\n               }\n               else\n               {\n                hset.add(p);\n               }\n            }\n            \n                return hset.size()-((nums2.length/2)-count2);\n\n        }\n        else if(count2==nums2.length/2)\n        {\n            HashSet<Integer> hset=new HashSet<Integer>();\n            for(Map.Entry<Integer,Integer> entry:h2.entrySet())\n            {\n                hset.add(entry.getKey());\n            }\n            for(Map.Entry<Integer,Integer> entry:h1.entrySet())\n            {\n               int p=entry.getKey();\n               if(hset.contains(p))\n               {\n                    if(count1<nums1.length/2)\n                    {\n                    count1++;\n                    }\n               }\n               else\n               {\n                hset.add(p);\n               }\n            }\n         \n                return hset.size()-((nums1.length/2)-count1);\n\n        }\n        else\n        {\n            HashSet<Integer> hset=new HashSet<Integer>();\n            for(Map.Entry<Integer,Integer> entry:h1.entrySet())\n            {\n                int p=entry.getKey();\n                if(h2.containsKey(p))\n                {\n                    if(count1<nums1.length/2)\n                    {\n                        count1++;\n                    }\n                    else\n                    {\n                        hset.add(p);\n                    }\n                }\n                else\n                {\n                    hset.add(p);\n                }\n            }\n\n            for(Map.Entry<Integer,Integer> entry:h2.entrySet())\n            {\n                int p=entry.getKey();\n                if(hset.contains(p))\n                {\n                    if(count2<nums2.length/2)\n                    {\n                        count2++;\n                    }\n                    else\n                    {\n                        hset.add(p);\n                    }\n                }\n                else\n                {\n                    hset.add(p);\n                }\n            }\n\n            return hset.size()-((nums1.length/2)-count1)-((nums2.length/2)-count2);\n        }\n     \n    }\n}\n```
['Java']