Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Merge K Lists

Python data engineering interview problem. Difficulty: advanced. Pattern: Heaps. About 18 minutes. Part of the Pro drill bank.

Merge k sorted lists into one sorted list. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement merge_k_lists(lists: list) -> list.

Requirements

  • Each inner list is sorted ascending.
  • Empty lists are allowed.

Examples

Input: merge_k_lists([[1, 4, 5], [1, 3, 4], [2, 6]]) Output: [1, 1, 2, 3, 4, 4, 5, 6] Heap merges heads.

Topics: lakebench, python, merge, heap.

More Python interview questions · All interview problems · Learn data engineering

advanced

Merge K Lists

Interview-style drill: Merge k sorted lists into one sorted list.

Implement `merge_k_lists(lists: list) -> list`. Example: `[[1, 4, 5], [1, 3, 4], [2, 6]]` → `[1, 1, 2, 3, 4, 4, 5, 6]`. Keep the harness.