2022-05-02 23:42:43 +08:00
|
|
|
|
<p>给你一个整数数组 <code>nums</code>,将 <code>nums</code> 中的的所有偶数元素移动到数组的前面,后跟所有奇数元素。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2022-05-02 23:42:43 +08:00
|
|
|
|
<p>返回满足此条件的 <strong>任一数组</strong> 作为答案。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
2022-05-02 23:42:43 +08:00
|
|
|
|
<p><strong>示例 1:</strong></p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2022-05-02 23:42:43 +08:00
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>nums = [3,1,2,4]
|
2022-03-27 20:46:41 +08:00
|
|
|
|
<strong>输出:</strong>[2,4,3,1]
|
2022-05-02 23:42:43 +08:00
|
|
|
|
<strong>解释:</strong>[4,2,3,1]、[2,4,1,3] 和 [4,2,1,3] 也会被视作正确答案。
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>nums = [0]
|
|
|
|
|
<strong>输出:</strong>[0]
|
2022-03-27 20:46:41 +08:00
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
2022-05-02 23:42:43 +08:00
|
|
|
|
<ul>
|
|
|
|
|
<li><code>1 <= nums.length <= 5000</code></li>
|
|
|
|
|
<li><code>0 <= nums[i] <= 5000</code></li>
|
|
|
|
|
</ul>
|