Challenge: Merge a Number of Sorted Arrays

In this lesson, you will solve the challenge of merging a number of sorted subarrays (an essential part of merge sort).

Merge k sorted arrays

Suppose there exists a k number of arrays (always a positive integer), each containing a fixed number of elements = n. Each individual array is sorted, and we want to merge all of the nkn * k elements into one sorted array.

Have a look at the following illustration. We initially have four arrays and each array has three elements:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.