1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 11:21:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part1

This commit is contained in:
2022-03-27 20:37:52 +08:00
parent 8e542045d1
commit c554fc6908
1285 changed files with 108123 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<p>给你一个数组 <code>nums</code> ,数组中有 <code>2n</code> 个元素,按 <code>[x<sub>1</sub>,x<sub>2</sub>,...,x<sub>n</sub>,y<sub>1</sub>,y<sub>2</sub>,...,y<sub>n</sub>]</code> 的格式排列。</p>
<p>请你将数组按 <code>[x<sub>1</sub>,y<sub>1</sub>,x<sub>2</sub>,y<sub>2</sub>,...,x<sub>n</sub>,y<sub>n</sub>]</code> 格式重新排列,返回重排后的数组。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [2,5,1,3,4,7], n = 3
<strong>输出:</strong>[2,3,5,4,1,7]
<strong>解释:</strong>由于 x<sub>1</sub>=2, x<sub>2</sub>=5, x<sub>3</sub>=1, y<sub>1</sub>=3, y<sub>2</sub>=4, y<sub>3</sub>=7 ,所以答案为 [2,3,5,4,1,7]
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [1,2,3,4,4,3,2,1], n = 4
<strong>输出:</strong>[1,4,2,3,3,2,4,1]
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>nums = [1,1,2,2], n = 2
<strong>输出:</strong>[1,2,1,2]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 500</code></li>
<li><code>nums.length == 2n</code></li>
<li><code>1 &lt;= nums[i] &lt;= 10^3</code></li>
</ul>