solving this by good approach for beginner easily to understand using set in java script
Intuition\nThe function maximumSetSize aims to determine the maximum size of a set formed from two input arrays, nums1 and nums2, with certain constraints. The 
# Intuition\nThe function maximumSetSize aims to determine the maximum size of a set formed from two input arrays, nums1 and nums2, with certain constraints. The constraints are based on the number of common elements between the two sets created from the input arrays. The idea is to maximize the size of a new set while adhering to the following conditions:\n\nThe total size of the new set cannot exceed half of the size of nums1.\nThe size of the new set also takes into account the unique elements from both sets while considering the common elements Describe your first thoughts on how to solve this problem.\n\n# Approach\nSet Creation: Convert both input arrays into sets (s1 and s2) to eliminate duplicates.\nCommon Elements: Iterate through one set and check for common elements in the other set. Store these common elements in a new set called common.\nCalculate Sizes:\nDetermine the size of the original arrays, the unique sizes of both sets, and the size of the common elements.\nReturn the Result: Calculate the maximum possible size of the new set using the formula:\nresult=min(n,min(n/2,n1\u2212c)+min(n/2,n2\u2212c)+c)\nHere, n is the length of nums1, n1 and n2 are the sizes of the unique sets, and c is the count of common elements.\n\n\n\n# Complexity\n- Time complexity:\nCreating sets from nums1 and nums2 takes O(n1 + n2), where n1 is the length of nums1 and n2 is the length of nums2.\nThe loop to find common elements iterates through s1 (size n1), and checking membership in s2 is O(1) on average. Thus, this part also takes O(n1).\nOverall, the time complexity is O(n1 + n2).\n\n- Space complexity:\nThe space complexity is determined by the space required to store the sets s1, s2, and common.\nThe maximum space used is proportional to the unique elements in both arrays, which is O(n1 + n2) in the worst case (if all elements are unique).\nTherefore, the space complexity is also O(n1 + n2).\n\n# Code\n```javascript []\n/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar maximumSetSize = function (nums1, nums2) {\n\tlet s1 = new Set(nums1);\n\tlet s2 = new Set(nums2);\n\tlet common = new Set();\n\t//now checking the common elements from the two set\n\tfor (let val of s1) {\n\t\tif (s2.has(val)) {\n\t\t\tcommon.add(val);\n\t\t}\n\t}\n\tlet n = nums1.length;\n\tlet n1 = s1.size;\n\tlet n2 = s2.size;\n\tlet c = common.size;\n\treturn Math.min(n, Math.min(n / 2, n1 - c) + Math.min(n / 2, n2 - c) + c);\n};\n```
['JavaScript']