[Python3] sets
Let N be the number of items we have to pick from each array.\n\nUse sets.  Among the elements that only occur in $A$ (ie. $A-B$), we pick them first, to a maxi
Let N be the number of items we have to pick from each array.\n\nUse sets.  Among the elements that only occur in $A$ (ie. $A-B$), we pick them first, to a maximum of $N$ elements.  Similarly for $B$.\n\nNow you have $2 N - \\text{onlyA} - \\text{onlyB}$ picks remaining, and you can pick from $A \\cap B$.\n\n# Code\n```\nclass Solution:\n    def maximumSetSize(self, A: List[int], B: List[int]) -> int:\n        N = len(A) // 2\n        A = set(A)\n        B = set(B)\n        onlyA = min(len(A - B), N)\n        onlyB = min(len(B - A), N)\n        both = min(len(A & B), 2 * N - onlyA - onlyB)\n        return onlyA + onlyB + both\n```
['Python3']