MaximumSetSize
Intuition\nThink of time Complexity while wirte the code. \n\n# Approach\nUse Greedy Approach to solve the problem.\n# Complexity\n- Time complexity:\nO(n)\n\n-
# Intuition\nThink of time Complexity while wirte the code. \n\n# Approach\nUse Greedy Approach to solve the problem.\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n# Code\n```\n/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar maximumSetSize = function (nums1, nums2) {\n    const set1 = new Set(nums1)\n    const set2 = new Set(nums2)\n\n\n    let overlap = 0\n    for (const n of set1) if (set2.has(n)) overlap++\n\n    const half = nums1.length / 2\n\n    return Math.min(\n\n        Math.min(set2.size - overlap, half)\n        + Math.min(set1.size - overlap, half)\n        + overlap,\n\n        half * 2\n\n    )\n};
['JavaScript']