Simple solution using set operations
Code\n\nclass Solution:\n    def maximumSetSize(self, nums1: List[int], nums2: List[int]) -> int:\n        s1, s2, n = set(nums1), set(nums2), len(nums1)\n     
# Code\n```\nclass Solution:\n    def maximumSetSize(self, nums1: List[int], nums2: List[int]) -> int:\n        s1, s2, n = set(nums1), set(nums2), len(nums1)\n        return min(\n           min(len(s1 - s2), n // 2)  # Numbers in s1 but not in s2, limited to n/2 as we have to pick max of n/2\n           + min(len(s2 - s1), n // 2)  # Numbers in s2 but not in s1, limited to n/2 as we have to pick max of n/2\n           + len(s1.intersection(s2)),  # Common numbers in both sets\n           n # The maximum result should not exceed n\n       )\n```
['Python3']