Two separate class sections already have their own sorted height lists, and Imran needs them combined into one single sorted line for the whole parade. Read two already-sorted arrays A (size N) and B (size M). Print the merged sorted array of size N+M without using a full O((N+M) log(N+M)) sort — use the classic O(N+M) merge technique from merge sort.
Input
Line1: N M. Line2: N integers (sorted). Line3: M integers (sorted).
Output
N+M integers, merged and sorted.
Constraints
1 ≤ N, M ≤ 10^5
Sample Input
3 2 1 4 7 2 5
Sample Output
1 2 4 5 7
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.