Easy To Understand Java Code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n  O(n)\n\n- Space complexity:\n  O(n)\n\n# Code\n```\nclass Solution {\n    public int maximumSetSize(int[] nums1, int[] nums2){\n\n    HashSet<Integer> set = new HashSet<>();\n    HashSet<Integer> set1 = new HashSet<>();\n    int numsl = nums1.length/2;\n    int nums1l = nums2.length/2;\n\n    for(int i : nums1){\n\n      if(!set.contains(i)) set.add(i);\n\n      else if(numsl > 0)  numsl--;\n\n    }\n\n    for(int i : nums2){\n \n       if(numsl > 0 && set.contains(i)){\n\n           set.remove(i);\n           numsl--;          \n\n       }   \n       if(!set1.contains(i)) set1.add(i);\n\n       else if(nums1l > 0) nums1l--;\n \n\n    }\n\n     set.stream().forEach(i -> {\n      if(set1.contains(i)) set1.remove(i);\n    });\n\n     \n\n       int res = set.size() > nums1.length/2 ? nums1.length/2 : set.size();\n       int res2  =  set1.size() > nums2.length/2 ? nums2.length/2 : set1.size();\n       \n       return res + res2;  \n  \n    }\n}\n```
['Java']