Given an integer array nums of length n, create an array ans of length 2n where ans[i] == nums[i] and ans[i+n] == nums[i] for all 0 ≤ i < n. Return ans.
nums = [1,2,1][1,2,1,1,2,1]ans[2*n]nums[i] → ans[i] (first half)nums[i] → ans[i+n] (second half)The result is simply nums repeated twice. We write each element to its original position i and also to position i+n (offset by the array length). One pass, no extra logic needed.