1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/摆动排序 II [wiggle-sort-ii].html
2022-03-29 12:43:11 +08:00

35 lines
1.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组 <code>nums</code>,将它重新排列成 <code>nums[0] < nums[1] > nums[2] < nums[3]...</code> 的顺序。</p>
<p>你可以假设所有输入数组都可以得到满足题目要求的结果。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,5,1,1,6,4]
<strong>输出:</strong>[1,6,1,5,1,4]
<strong>解释:</strong>[1,4,1,5,1,6] 同样是符合题目要求的结果,可以被判题程序接受。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,3,2,2,3,1]
<strong>输出:</strong>[2,3,1,3,1,2]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= nums.length <= 5 * 10<sup>4</sup></code></li>
<li><code>0 <= nums[i] <= 5000</code></li>
<li>题目数据保证,对于给定的输入 <code>nums</code> ,总能产生满足题目要求的结果</li>
</ul>
<p> </p>
<p><strong>进阶:</strong>你能用 O(n) 时间复杂度和 / 或原地 O(1) 额外空间来实现吗?</p>