JavaScript set and logic operations
Intuition\n Describe your first thoughts on how to solve this problem. \nThis solution was inspired by @blackbrain2009\n\n\n# Approach\n Describe your approach 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis solution was inspired by [@blackbrain2009](https://leetcode.com/problems/maximum-size-of-a-set-after-removals/solutions/4520698/hash-table-math-t-o-n)\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nStep 1: You get the unique numbers of each array\nStep 2: You get the number of unique elements that appear in both arrays\nStep 3: You get the unique elements that do not appear in the other array and cap how many you can get to half the length, then you add the unique elements that appear in both arrays. If the answer is more than the needed length you return the full length of the array\n\n# Complexity\n- Time complexity: $$O(m + n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(m + n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar maximumSetSize = function(nums1, nums2) {\n  const d1 = new Set(nums1), d2 = new Set(nums2);\n\n  let len1 = d1.size, len2 = d2.size, eq = 0;\n\n  for (const key of d1) {\n    if (d2.has(key)) eq++;\n  }\n\n  const halfLength = nums1.length / 2;\n  \n  return Math.min(Math.min(len2 - eq, halfLength) + Math.min(len1 - eq, halfLength) + eq, halfLength*2)\n};\n```
['JavaScript']