mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 23:11:41 +08:00
update
This commit is contained in:
34
leetcode/problem/concatenation-of-array.html
Normal file
34
leetcode/problem/concatenation-of-array.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<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>
|
||||
|
||||
<p>Specifically, <code>ans</code> is the <strong>concatenation</strong> of two <code>nums</code> arrays.</p>
|
||||
|
||||
<p>Return <em>the array </em><code>ans</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,2,1]
|
||||
<strong>Output:</strong> [1,2,1,1,2,1]
|
||||
<strong>Explanation:</strong> The array ans is formed as follows:
|
||||
- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]
|
||||
- ans = [1,2,1,1,2,1]</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,3,2,1]
|
||||
<strong>Output:</strong> [1,3,2,1,1,3,2,1]
|
||||
<strong>Explanation:</strong> The array ans is formed as follows:
|
||||
- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]
|
||||
- ans = [1,3,2,1,1,3,2,1]
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>n == nums.length</code></li>
|
||||
<li><code>1 <= n <= 1000</code></li>
|
||||
<li><code>1 <= nums[i] <= 1000</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user