Back to DSA

Merge K Sorted Lists

hard
Acceptance: 41%
HeapLinked ListDivide and Conquer

You have k linked lists, each individually sorted in non-decreasing order. Combine them all into a single sorted linked list and return it.

Examples

Example 1:
Input:lists = [[2,5,8],[1,4,6],[3,7]]
Output:[1,2,3,4,5,6,7,8]
Example 2:
Input:lists = [[]]
Output:[]

Hints

00:00
1234567