Understanding leetcode problem

I am attempting to do this leetcode problem here: Loading...

I am having trouble with this wording…the way it is worded is throwing me off.

" 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)."

What does it mean by "of length 2n?

2n means twice as long as the original array (which has length n). Look at the examples to see what they want you to do.

Input array: [1,2,1]
Output array: [1,2,1,1,2,1]

Do you see how the output array is just the input array twice, one after the other?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.