#164

Merge K Sorted Log Streams

MEDIUMHeapPYTHON

Problem Description

(1) **Input:** `k` log streams—each stream is a list of `[timestamp, message]` entries sorted by timestamp. (2) **Task:** Merge all streams into one ordered stream by timestamp. (3) **Tie-breaking:** When timestamps are equal, use stable merge—entries from lower-indexed streams first. (4) **Output:** A single list of `[timestamp, message]` in ascending timestamp order. (5) **Data:** Streams may be empty; timestamps are integers, messages are strings.

Topics

arrayheap

Asked at Companies

microsoft

Solve This Problem

Sign up to access the interactive code editor, run test cases, view the editorial, and get AI-powered feedback on your solution.

Start Solving →