Each sensor produces a log: a list of timestamps in ascending order. Given logs, a list of such lists, return one list with every timestamp in ascending order. Equal timestamps from different sensors all appear in the output. Some logs may be empty, and logs itself may be empty.
Do not simply concatenate and sort; merge the logs using the fact that each is already sorted.
Examples
Input: logs = [[1, 4, 7], [2, 5], [0, 6, 8]]
Output: [0, 1, 2, 4, 5, 6, 7, 8]
Input: logs = [[], [3, 3], [1]]
Output: [1, 3, 3]
Constraints
0 <= len(logs) <= 10**4, total number of timestampsN <= 2 * 10**5- Timestamps are integers in
[-10**9, 10**9]. - Target complexity: O(N log k) where
kis the number of logs.
Goals
- Track one cursor per input list inside a single heap
- Always emit the globally smallest pending value
- Handle empty logs and logs of very different lengths