A chain of harbor buoys transmits a sequence of numeric signal codes once during its morning broadcast. The instant that pass finishes, every buoy re-transmits the exact same codes in reverse order as an echo confirmation, and harbor control logs the two passes back-to-back as a single continuous broadcast record.
Given the original sequence of signal codes, reconstruct the full broadcast record: the original sequence followed immediately by the same codes written in reverse order.
n, the number of signal codes in the original broadcast.n space-separated integers, the signal codes in the order they were first transmitted.Print 2n space-separated integers on a single line: the n original codes in their given order, followed by the same n codes in reverse order.
1 <= n <= 1000-1000 <= code[i] <= 1000Example 1
Input
4 1 2 3 4
Expected
1 2 3 4 4 3 2 1
Explanation
The original broadcast logs 1 2 3 4 in order. The echo pass then re-transmits the same codes in reverse: 4 3 2 1. Logged back-to-back, the full record is 1 2 3 4 4 3 2 1.
Example 2
Input
1 7
Expected
7 7
Explanation
With only one signal code, reversing it changes nothing, so the echo pass repeats 7. The full record is 7 7.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →