Merge Two Sorted Lists

Medium 40 XPArraysTwo PointersSorting

Commonly asked at Amazon, Microsoft, Google

Read two sorted lists of integers (one per line) and print them merged into one sorted list. Don't just call sort() — merge them with two pointers.

Input
Two lines of space-separated sorted integers.
Output
The merged sorted list.

Sample 1

Input

1 3 5 7
2 4 6

Output

1 2 3 4 5 6 7

Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.
The solution unlocks after 3 submissions.