Problem · Array
Merge Three Sorted Arrays
Learn this problemProblem statement
You are given three integer arrays that are each sorted in non-decreasing order.
Merge the arrays into one sorted array and remove duplicate values. Return the merged array in non-decreasing order.
Function
mergeThreeSortedArrays(a: int[], b: int[], c: int[]) → int[]Complete the function mergeThreeSortedArrays in the editor.
mergeThreeSortedArrays has the following parameters:
int a[]: the first sorted arrayint b[]: the second sorted arrayint c[]: the third sorted array
Returns
int[]: the sorted merged array with duplicates removed
Examples
Example 1
a = [1, 3, 5]b = [1, 2, 5, 6]c = [2, 4, 6]return = [1, 2, 3, 4, 5, 6]After merging all values and removing duplicates, the sorted result is [1, 2, 3, 4, 5, 6].
Example 2
a = []b = [0, 0, 1]c = [1, 2]return = [0, 1, 2]Empty arrays are allowed. Duplicate 0 and 1 values are returned once.
Constraints
- Each input array is sorted in non-decreasing order.
- The arrays may contain duplicate values.
- The arrays may be empty.
More Meta problems
- Plan a Minimum-Cost Round TripONSITE INTERVIEW · Seen Jul 2026
- Highest Rating Price RatioOA · Seen Mar 2026
- Diagonal Traverse (for E4 ;)PHONE SCREEN · Seen Mar 2025
- Find Peak ElementPHONE SCREEN · Seen Mar 2025
- Find Pair Closest to K (for E5 :)PHONE SCREEN · Seen Feb 2025
- Get Minimum Round Trip Cost (: for E4 && E5 :)PHONE SCREEN · Seen Feb 2025
- Max Consecutive Ones III (for E5 :)PHONE SCREEN · Seen Feb 2025
- Sliding Window Average (Meta Canada, E4/E5 :)PHONE SCREEN · Seen Dec 2024