Merge Sorted Rows
Merge several sorted rows into one sorted list with a heap that holds one value per row.
The problem
Implement merge_sorted_rows(rows). rows is a list of rows, and each row is a list of integers sorted in ascending order. Any row may be empty, and rows itself may be empty. Return one ascending list with every value from every row, keeping repeated values. Use a heap that holds at most one value from each row at a time.
Starter code
def merge_sorted_rows(rows):
passPublic examples
rows = [[1, 4, 9], [2, 2, 8], [3, 7]]gives[1, 2, 2, 3, 4, 7, 8, 9]rows = [[], [1, 5], []]gives[1, 5]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
