Your question is Merge Three Sorted Lists. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Meta Logistics Dispatch receives three delivery-ID lists that are already sorted in nondecreasing order. Implement a function that merges them into one sorted list containing every ID from all three inputs.
Given three Python lists list1, list2, and list3, where each list contains integers sorted in nondecreasing order, return a new list containing all elements from the three input lists in nondecreasing order. Do not modify the input lists. Duplicate values must be preserved.
Aim for a solution that runs in linear time relative to the total number of elements and uses only constant auxiliary space beyond the returned list.
def merge_sorted_lists(list1, list2, list3):