451. Intersection of Three Sorted Arrays
Given three integer arrays arr1, arr2, and arr3 sorted in strictly increasing order, return a sorted array containing only the integers that appear in all three arrays.
Example 1:
Input: arr1 = [2, 4, 6, 8, 10], arr2 = [4, 6, 8, 12, 14], arr3 = [1, 4, 6, 8, 16]
Output: [4, 6, 8]
Explanation:
The numbers 4, 6, and 8 appear in all three arrays.
Example 2:
Input: arr1 = [3, 7, 15, 20, 25], arr2 = [1, 2, 3, 7, 10, 15], arr3 = [3, 5, 7, 15, 18]
Output: [3, 7, 15]
Explanation:
The numbers 3, 7, and 15 are present in all three arrays.
Now Your Turn!
Pick the correct output for the given inputInput: arr1 = [10, 30, 50, 70], arr2 = [20, 40, 60, 80], arr3 = [5, 15, 25, 35]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 ≤ arr1.length, arr2.length, arr3.length ≤ 1000
- 1 ≤ arr1[i], arr2[i], arr3[i] ≤ 2000
- All three arrays are sorted in strictly increasing order.