Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed). Specifically, ans is the concatenation of two nums arrays. Return the array ans.
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed). Specifically, ans is the concatenation of two nums arrays. Return the array ans.
Example 1:
Input: {"nums":[1,2,1]}
Output: [1,2,1,1,2,1]
Constraints:
n==nums.length
1≤n≤1000
1≤nums[i]≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[1,2,1]}
ans has 2n = 6 slots: the first half (0..2) and the second half (3..5). Every nums[i] lands once in each half, at i and at i + n.