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.
Create an array to hold the concatenated array. The goal is to repeat the array twice in a new array. Therefore, it is easy to repeat as so: ans = [nums, nums] = [nums[0], nums[1], nums[2], ..., nums[0], nums[1], nums[2], ...]
Create an array that has size nums.size x 2
Run through every number in nums and add it twice.
First add to [i]
Then add to [i+nums.size]
ans[i] = nums[i]
ans[i+nums.size] = nums[i]
For example: nums = [1, 2, 3]
ans = a new int array of size 2*3 = 6
(At iteration i = 0) ans = [1, 0, 0, 1, 0, 0] (int arrays are initialized with 0s)
(At iteration i = 1) ans = [1, 2, 0, 1, 2, 0]
(At iteration i = 2) ans = [1, 2, 3, 1, 2, 3]