Java | Simplistic Set
\n\n# Code\n\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        Set<Integer> sA = Arrays.stream(nums1).boxed().collect(Collec
\n\n# Code\n```\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2) {\n        Set<Integer> sA = Arrays.stream(nums1).boxed().collect(Collectors.toCollection(HashSet::new));\n        Set<Integer> sB = Arrays.stream(nums2).boxed().collect(Collectors.toCollection(HashSet::new));\n\n        int sizeA = nums1.length / 2;\n        int sizeB = nums2.length / 2;\n\n        if (sizeA <= sA.size() && sizeB <= sB.size()) {\n            sA.addAll(sB);\n            return Math.min(sizeA + sizeB, sA.size());\n        } else {\n            if (sizeA > sA.size()) {\n                for (int k : sA) {\n                    sB.remove(k);\n                }\n            }\n\n            if (sizeB > sB.size()) {\n                for (int k : sB) {\n                    sA.remove(k);\n                }\n            }\n        }\n\n        return Math.min(sA.size(), sizeA) + Math.min(sB.size(), sizeB);\n    }\n}\n\n```
['Java']