A gateway received k telemetry logs. Each log is already sorted in non-decreasing order. Merge all logs into a single non-decreasing sequence and print every value in order (duplicates included).
Line 1: an integer k, the number of logs.
Next k lines: each line starts with an integer L (the log's length) followed by L non-decreasing integers. L may be 0 (an empty log, so the line is just 0).
One line containing all merged values in non-decreasing order, space-separated. If there are no values at all, print an empty line.
Example 1
Input
3 2 1 5 3 2 3 8 1 4
Expected
1 2 3 4 5 8
Explanation
The logs are [1,5], [2,3,8], [4]. Merged in order: 1 2 3 4 5 8.
Example 2
Input
2 0 3 -2 0 7
Expected
-2 0 7
Explanation
The first log is empty; the second is [-2,0,7]. The merged sequence is -2 0 7.
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 →