The Intersection of Three Sorted Arrays interview question asks you to find all the numbers that are present in three different arrays. Crucially, all three input arrays are already sorted in strictly increasing order.
Companies like Apple and Meta use this to test your ability to leverage the Sorted property. While a Hash Map approach ( space) is valid, the interviewer is usually looking for the space Two Pointers (or in this case, Three Pointers) approach. It tests your proficiency with Array interview patterns.
This problem uses the Multiple Pointers pattern.
p1 = 0, p2 = 0, p3 = 0.arr1[p1] == arr2[p2] == arr3[p3], you found a common element. Add it to result and increment all three pointers.A = [1, 2, 5], B = [2, 3, 5], C = [2, 5, 8]
p1=0(1), p2=0(2), p3=0(2). A is smallest. p1++.p1=1(2), p2=0(2), p3=0(2). All equal! Add 2. p1++, p2++, p3++.p1=2(5), p2=1(3), p3=1(5). B is smallest. p2++.p1=2(5), p2=2(5), p3=1(5). All equal! Add 5.
Result: [2, 5].Always look for "Two Pointers" when multiple arrays are sorted. Moving pointers based on relative magnitude is a fundamental Sorting interview pattern that avoids comparisons.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Best Poker Hand | Easy | Solve | |
| Maximum Count of Positive Integer and Negative Integer | Easy | Solve | |
| Find Lucky Integer in an Array | Easy | Solve | |
| Sum of Unique Elements | Easy | Solve | |
| Count Elements With Maximum Frequency | Easy | Solve |