Two graders each hand back a list of exam scores already sorted in non-decreasing order. Combine them into a single non-decreasing list that contains every score from both lists (duplicates kept).
Line 1: two integers n and m, the lengths of the two lists.
Line 2: n non-decreasing integers, the first list.
Line 3: m non-decreasing integers, the second list.
One line: the n + m merged scores in non-decreasing order, space-separated.
Example 1
Input
3 3 1 4 7 2 3 8
Expected
1 2 3 4 7 8
Explanation
Interleaving the two ascending lists yields 1 2 3 4 7 8.
Example 2
Input
2 4 5 5 1 5 6 9
Expected
1 5 5 5 6 9
Explanation
Both fives from the first list are placed among the second list's values, giving 1 5 5 5 6 9.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →