Two Out of Three - Problem
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.
Input & Output
Example 1 — Basic Case
$
Input:
nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]
›
Output:
[2,3]
💡 Note:
Value 2 appears in nums1 and nums2. Value 3 appears in all three arrays. Value 1 only appears in nums1.
Example 2 — No Overlap
$
Input:
nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]
›
Output:
[1,2,3]
💡 Note:
Value 1 appears in nums1 and nums3. Value 2 appears in nums2 and nums3. Value 3 appears in nums1 and nums2.
Example 3 — Single Array Only
$
Input:
nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]
›
Output:
[]
💡 Note:
No value appears in at least two arrays, so the result is empty.
Constraints
- 1 ≤ nums1.length, nums2.length, nums3.length ≤ 100
- 1 ≤ nums1[i], nums2[j], nums3[k] ≤ 100
Visualization
Tap to expand
Understanding the Visualization
1
Input
Three integer arrays with potentially overlapping values
2
Process
Identify values appearing in 2 or more arrays
3
Output
Return distinct values meeting the criteria
Key Takeaway
🎯 Key Insight: Use hash maps to efficiently track which arrays contain each value
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code