Simple logical thinking 
IntuitionApproachComplexity
Time complexity: O(n)

Space complexity:O(n)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->


- Space complexity:O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int maximumSetSize(int[] nums1, int[] nums2) {
        
        HashMap<Integer,Integer> map=new HashMap<>();
        int distinctUniqueToArray1=0, distinctUniqueToArray2=0,distinctCommonToBoth=0;

/*
We will mark all those numbers unique to Array1 with value 1 in the map
We will mark all those numbers unique to Array2 with value 2 in the map
We will mark all those numbers common to both Array1 and Array2 with value 3 in the map
*/
        for(int i=0;i<nums1.length;i++)
        {
            if(!map.containsKey(nums1[i])) 
            {
                map.put(nums1[i],1);
                distinctUniqueToArray1++;
            }
        }

        for(int i=0;i<nums2.length;i++)
        {
            if(!map.containsKey(nums2[i]))
            {
                map.put(nums2[i],2);
                distinctUniqueToArray2++;
            }
            else
            {
                int j=map.get(nums2[i]);
                if(j==1)
                  {
                    distinctUniqueToArray1--;
                    map.put(nums2[i],3);
                    distinctCommonToBoth++;
                  }
            }
        }

        int k=Math.min(nums1.length/2,distinctUniqueToArray1); //no of choices filled out of a total n/2 from Array 1 taking elements present only in Array1
        int K=Math.max(0,nums1.length/2-k);// no of choices left to be made from Array1 
      
        int m=Math.min(nums1.length/2,distinctUniqueToArray2);//no of choices filled out of a total n/2 from Array2 taking elements present only in Array2
        int M=Math.max(0,nums1.length/2-m);// no of choices left to be made from Array1 

        return k+m+Math.min(distinctCommonToBoth,K+M);
        

        

        
    }
}
```
['Java']