Back to DSA sheet
Concatenation of Array
EasyArraysGiven an array of length n, return an array of length 2n that is the original followed by the original again: ans[i] = nums[i] and ans[i+n] = nums[i].
Input format (stdin): the first line has n. The second line has n integers. Output the 2n values separated by spaces.
Examples
Input: 3
1 2 1
Output: 1 2 1 1 2 1
Input: 2
1 3
Output: 1 3 1 3
Constraints
- 1 <= n <= 1000
- 1 <= nums[i] <= 1000
Sheets
NeetCode 250
concatenation-of-array.cpp2 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.