
Merge sorted delivery times
easyMerge sorted delivery times
DoorDash Python Interview Question
DoorDash combines delivery times from two regions into one report. Each region's list is already sorted from fastest to slowest.
Write a function merge_sorted(first, second) that takes two sorted lists of delivery times in minutes and returns one sorted list containing every time from both, including repeats.
Asked of
- Data Engineer
- Data Scientist
- Analytics Engineer
- ML Engineer
- AI Engineer
Example 1
Input
merge_sorted([12, 25, 40], [5, 30])
Output
[5, 12, 25, 30, 40]
Example 2
Input
merge_sorted([], [3, 4])
Output
[3, 4]
Explanation
In the first example, the combined times in order are 5, 12, 25, 30 and 40. In the second example, the first list is empty, so the answer is simply the second list.
Submit also runs 3 hidden test cases that check edge cases.
Company
DoorDash
Difficulty
easy
Topic
two pointers
Language
Python
Your code
Loading Python in the background. You can start writing.