Build a new array by appending the input array to itself once.
Given an integer array nums, construct a new array ans such that:
ans.length = 2 * nums.lengthi, ans[i] = nums[i]i, ans[i + nums.length] = nums[i]In other words, return the concatenation of the array with itself.
nums.nums followed by nums again.0 <= nums.lengthnums: integer array2 * nums.lengthExample 1
Input
nums = [1,2,1]
Output
[1,2,1,1,2,1]
Explanation
The array is appended to itself once.
Example 2
Input
nums = [0,3,5,7]
Output
[0,3,5,7,0,3,5,7]
Explanation
Copy the full array in order, then repeat the same sequence.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.