cswork / OAOpen practice workspace

OracleOA #9

Merge 2 Arrays

Estimated EasyJudge-ready

Topics (AI-labelled)Two Pointers

Merge two non-decreasing arrays into one non-decreasing array, keeping all duplicate values.

Input

The first line contains the common length n, followed by two lines each with n integers. Full original bounds: 1<n≤100000, 0≤element≤10^9, and each array is non-decreasing.

Output

Output the 2n merged integers, separated by spaces. The original return signature int[n] does not match the statement, so all 2n items are kept here as the statement requires.

Example 1

Input:

3
1 2 3
2 5 5

Output:

1 2 2 3 5 5

Example 2

Input:

2
0 0
0 1

Output:

0 0 0 1

Example 3

Input:

2
4 5
1 3

Output:

1 3 4 5

Example notes

The outputs of the three public examples are, in order: 1 2 2 3 5 5; 0 0 0 1; 1 3 4 5. They were verified by independent enumeration or direct simulation.

Editorial

Loading solution…