scala solution
\nobject Solution {\n  def maximumSetSize(nums1: Array[Int], nums2: Array[Int]): Int = {\n    val (set1,set2,n) = (nums1.to(Set), nums2.to(Set),nums1.size)\n   
```\nobject Solution {\n  def maximumSetSize(nums1: Array[Int], nums2: Array[Int]): Int = {\n    val (set1,set2,n) = (nums1.to(Set), nums2.to(Set),nums1.size)\n    val both = set1.count(set2.contains(_))\n    ((set1.size - both).min(n>>1) + (set2.size - both).min(n>>1) + both) min n\n  }\n}}```
['Scala']