Coding Challenge

Merge k Sorted Lists

Hard
linked-listheapdivide-and-conquer

Merge many sorted linked lists into one sorted list.

You are given an array of sorted linked list heads. Merge them into one sorted linked list and return its head.

Examples

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

Output: [1,1,2,3,4,4,5,6]

Constraints

  • k may be zero
  • Lists may be empty

Preparing your coding workspace...