Merge K Sorted Lists

Problem Merge k sorted singly linked lists into a single sorted linked list and return its head.

Input / Output

  • Input: an array of k list heads, each list sorted ascending (any may be empty/null).
  • Output: the head of one merged, ascending-sorted list.

Constraints

  • 0 ≤ k ≤ 10^4; total nodes across all lists can be large.
  • Lists may be empty; the whole input may be empty (return null).

Example

  • [[1,4,5],[1,3,4],[2,6]] → [1,1,2,3,4,4,5,6].
added …
LeaderboardSalaryAccount