Challenge: Merge a Number of Sorted Arrays

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

Merge K Sorted Arrays

Suppose there are k (positive integer) arrays, each with a fixed number of elements (n). Each individual array is sorted, and we want to merge all of the nkn * k elements into one array in sorted order. Refer to the following illustration where 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.