DIY: Merge K Sorted Lists

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

Problem statement

You will be given multiple sorted lists and your task is to merge them into a single sorted list.


The input will be a list of multiple sorted lists. The following is an example of input:



The output should be a single sorted list. 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 list of multiple sorted lists. This function will return a single list of sorted numbers.

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