Skip to content
UPEEC

Merge Two Sorted Arrays

Easy#arrays#two-pointers#sorting· solved by 0 · time limit 2.0 s

Merge two arrays that are already sorted in non-decreasing order into one sorted array — in O(n+m)O(n+m) using two pointers.

Input

nn and the first array, then mm and the second array.

Output

The merged array.

Constraints

1≤n,m≤1051 \le n, m \le 10^5

Sample 1

Input

3
1 3 5
4
2 3 4 10

Output

1 2 3 3 4 5 10

Sign in or join free to run and submit your solution.