1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/峰与谷 [peaks-and-valleys-lcci].html

14 lines
549 B
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>在一个整数数组中,&ldquo;&rdquo;是大于或等于相邻整数的元素,相应地,&ldquo;&rdquo;是小于或等于相邻整数的元素。例如,在数组{5, 8, 4, 2, 3, 4, 6}中,{8, 6}是峰, {5, 2}是谷。现在给定一个整数数组,将该数组按峰与谷的交替顺序排序。</p>
<p><strong>示例:</strong></p>
<pre><strong>输入: </strong>[5, 3, 1, 2, 3]
<strong>输出:</strong>&nbsp;[5, 1, 3, 2, 3]
</pre>
<p><strong>提示:</strong></p>
<ul>
<li><code>nums.length &lt;= 10000</code></li>
</ul>