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)/旋转数组的最小数字 [xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof].html
2022-03-29 12:43:11 +08:00

35 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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>把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。</p>
<p>给你一个可能存在&nbsp;<strong>重复</strong>&nbsp;元素值的数组&nbsp;<code>numbers</code>&nbsp;,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的<strong>最小元素</strong>。例如,数组&nbsp;<code>[3,4,5,1,2]</code><code>[1,2,3,4,5]</code> 的一次旋转,该数组的最小值为 1。&nbsp;&nbsp;</p>
<p>注意,数组 <code>[a[0], a[1], a[2], ..., a[n-1]]</code> 旋转一次 的结果为数组 <code>[a[n-1], a[0], a[1], a[2], ..., a[n-2]]</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong><code>numbers = </code>[3,4,5,1,2]
<strong>输出:</strong>1
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong><code>numbers = </code>[2,2,2,0,1]
<strong>输出:</strong>0
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == numbers.length</code></li>
<li><code>1 &lt;= n &lt;= 5000</code></li>
<li><code>-5000 &lt;= numbers[i] &lt;= 5000</code></li>
<li><code>numbers</code> 原来是一个升序排序的数组,并进行了 <code>1</code><code>n</code> 次旋转</li>
</ul>
<p>注意:本题与主站 154 题相同:<a href="https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/">https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/</a></p>