Imagine you're analyzing voting patterns across three different regions. Given three integer arrays nums1, nums2, and nums3, you need to find all the popular values that appear in at least two out of the three arrays.
Your task is to return a distinct array containing all values that have this "majority support" - appearing in 2 or more of the input arrays. The order of values in your result doesn't matter, but each value should appear only once.
Example: If nums1 = [1,1,3,2], nums2 = [2,3], and nums3 = [3], then value 2 appears in arrays 1 and 2, while 3 appears in all three arrays. So the answer is [2,3].
Input & Output
Visualization
Time & Space Complexity
Single pass through all three arrays to build the hash map
Space for hash map storing unique elements, where k is number of distinct elements
Constraints
- 1 โค nums1.length, nums2.length, nums3.length โค 100
- 1 โค nums1[i], nums2[j], nums3[k] โค 100
- All values are positive integers
- Arrays can contain duplicate elements