← All problems

Merge K Sorted Lists

Hard linked listsheaps LeetCode ↗
Merge k sorted linked lists into one sorted list and return its head. A naive pairwise merge is too slow for large k — find the optimal strategy and analyze its complexity.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(N log k), Space O(k)

Common pitfalls

  • Pairwise merging (TLE)
  • Forgetting to push next after pop

Your solution

Log in to save your code and track progress.