Merge K Sorted Lists

Problem Merge k sorted linked lists into a single sorted list. (This mirrors merging postings lists in a search engine.)

Input / Output

  • Input: an array of k sorted linked lists (some may be empty).
  • Output: one merged sorted linked list containing every node.

Constraints

  • 0 ≤ k ≤ 10^4; the total number of nodes N can be large.
  • Each list is individually sorted in non-decreasing order.

Example

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