HARD

Merge K Sorted Lists

Data Structures & AlgorithmsLinked ListHeapDivide and ConquerMerge Sort

Problem Description

You are given an array of k linked-lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list and return it.

Example

Input
lists = [[1,4,5],[1,3,4],[2,6]]
Output
[1,1,2,3,4,4,5,6]

Constraints

Time: 3s
Memory: 256MB