I'm looking for the fastest way to merge multiple pre-sorted arrays, into one sorted array, without duplicates.
For example:
const arrays = [
[15, 30, 35, 40, 45, 50],
[33, 36, 39, 42, 45, 48],
[37, 38, 39, 40, 41, 42]
];
Should output:
[15, 30, 33, 35, 36, 37, 38, 39, 40, 41, 42, 45, 48, 50]
In reality these arrays are much larger so I'm looking for a fast way to do this.
This question is about performance I'm aware it can be done in with concat and sort in O(n log(n)) but I'm looking for something O(n).