DIY: Merge K Sorted Lists

Solve the interview question "Merge K Sorted Lists" yourself in this lesson.

We'll cover the following

Problem statement

Now, you will be given multiple sorted arrays and your task is to merge them into a single sorted array.


The input will be an array of multiple sorted array. The following is an example of input:



The output should be a single sorted array. For the above input, the output should be:


Coding exercise

For this coding exercise, you need to implement the function mergeKLists(lists), where lists is the array of multiple sorted arrays. This function will return a single array of sorted numbers.

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