Two Out of Three

Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.

Example 1
Inputnums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]
Output[3,2]
The values present in at least two arrays are 3, which is in all three arrays, and 2, which is in nums1 and nums2.
Example 2
Inputnums1 = [3,1], nums2 = [2,3], nums3 = [1,2]
Output[2,3,1]
The values present in at least two arrays are 2 in nums2 and nums3, 3 in nums1 and nums2, and 1 in nums1 and nums3.

Constraints

  • 1 <= nums1.length, nums2.length, nums3.length <= 100
  • 1 <= nums1[i], nums2[j], nums3[k] <= 100

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate