01 · Question
Given m ascending integer arrays, return all their values in ascending order, preserving duplicates. Empty arrays and an empty collection are allowed.
Example: [[1,4], [], [1,3,5]] returns [1,1,3,4,5].
02 · Analysis
Keep one pending item per nonempty stream, together with its stream ID and index. The smallest pending head is the smallest remaining value globally. Pop it, emit it, then insert only its successor. Heapify the initial heads in O(m); with N outputs, total time is O(m + N log(m+1)), auxiliary space O(m), output space O(N). Stopping after k outputs gives the chapter's top-k-across-sorted-lists variation without inspecting all N values.