Merge K Sorted Arrays
Mediumjavapythonccppjavascript
Given K sorted arrays, merge them into a single sorted array.
Input Format
The first line contains an integer K. Each of the next K lines describes one array: it starts with its length L, followed by L space-separated integers in non-decreasing order.
Output Format
Print all the values merged into one non-decreasing sequence, separated by single spaces.
Example 1
Input
3 3 1 4 7 3 2 5 8 3 3 6 9
Output
1 2 3 4 5 6 7 8 9
Explanation: All elements from the three arrays in sorted order.
- 1 <= K <= 10000
- Total number of elements <= 100000
- -1000000000 <= value <= 1000000000