Merge Two Ordered Runs
Merge two sorted lists into one sorted list in a single pass.
The problem
Implement merge_ordered_runs(left, right). Both lists are sorted in nondecreasing order. Return one sorted list that contains every value from both lists, keeping duplicates. For example, [1, 4, 7] and [2, 3, 8] give [1, 2, 3, 4, 7, 8], and [1, 2, 2] and [2, 3] give [1, 2, 2, 2, 3]. Do not call sorted(); build the result in one pass over the two lists. Either list may be empty.
Starter code
def merge_ordered_runs(left, right):
passPublic examples
left = [1, 4, 7], right = [2, 3, 8]gives[1, 2, 3, 4, 7, 8]left = [1, 2, 2], right = [2, 3]gives[1, 2, 2, 2, 3]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
