398. Merge K sorted Arrays
0
Medium
Given K sorted arrays, each containing N elements, merge them together and output the resulting sorted array.
Input Format
The first line of input consists of two space-separated integers, K and N. The following K*N lines contain space-separated integers representing the elements of the arrays.
Output Format
The output should be a single line consisting of space-separated numbers.
Example
Input
3 4
1 3 5 7
2 4 6 8
0 9 10 11
Output
0 1 2 3 4 5 6 7 8 9 10 11
Constraints
The elements in each array are less than or equal to |10^15|. The number of elements in each array, N, is less than or equal to 10^5. The number of arrays, K, is less than or equal to 10.
Loading...
View Submissions
Console