|
| 1 | +<h2><a href="https://leetcode.com/problems/concatenation-of-array">2058. Concatenation of Array</a></h2><h3>Easy</h3><hr><p>Given an integer array <code>nums</code> of length <code>n</code>, you want to create an array <code>ans</code> of length <code>2n</code> where <code>ans[i] == nums[i]</code> and <code>ans[i + n] == nums[i]</code> for <code>0 <= i < n</code> (<strong>0-indexed</strong>).</p> |
| 2 | + |
| 3 | +<p>Specifically, <code>ans</code> is the <strong>concatenation</strong> of two <code>nums</code> arrays.</p> |
| 4 | + |
| 5 | +<p>Return <em>the array </em><code>ans</code>.</p> |
| 6 | + |
| 7 | +<p> </p> |
| 8 | +<p><strong class="example">Example 1:</strong></p> |
| 9 | + |
| 10 | +<pre> |
| 11 | +<strong>Input:</strong> nums = [1,2,1] |
| 12 | +<strong>Output:</strong> [1,2,1,1,2,1] |
| 13 | +<strong>Explanation:</strong> The array ans is formed as follows: |
| 14 | +- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]] |
| 15 | +- ans = [1,2,1,1,2,1]</pre> |
| 16 | + |
| 17 | +<p><strong class="example">Example 2:</strong></p> |
| 18 | + |
| 19 | +<pre> |
| 20 | +<strong>Input:</strong> nums = [1,3,2,1] |
| 21 | +<strong>Output:</strong> [1,3,2,1,1,3,2,1] |
| 22 | +<strong>Explanation:</strong> The array ans is formed as follows: |
| 23 | +- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]] |
| 24 | +- ans = [1,3,2,1,1,3,2,1] |
| 25 | +</pre> |
| 26 | + |
| 27 | +<p> </p> |
| 28 | +<p><strong>Constraints:</strong></p> |
| 29 | + |
| 30 | +<ul> |
| 31 | + <li><code>n == nums.length</code></li> |
| 32 | + <li><code>1 <= n <= 1000</code></li> |
| 33 | + <li><code>1 <= nums[i] <= 1000</code></li> |
| 34 | +</ul> |
0 commit comments