Merge Sorted Streams
Merge k sorted lists into a single sorted list.
Requirements
- Run in time, where is the total number of elements, using a min-heap. Do not just concatenate and sort.
Examples
EXAMPLE WALKTHROUGHthree lists
A guided view of the published example, not a trace of your code.
INPUT
[[[1,4,5],[1,3,4],[2,6]]]TASKmerge_sorted_streams()
EXPECTED OUTPUT
[1,1,2,3,4,4,5,6]Start with the input values shown in this example.
Example 1 of 3
Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
Explanation: three lists
Input: lists = []
Output: []
Explanation: no lists
Input: lists = [[],[]]
Output: []
Explanation: empty lists
Hint 1
Push the first element of each list onto a heap along with its list index and position.