mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 09:21:40 +08:00
39 lines
993 B
HTML
39 lines
993 B
HTML
<p>给定一个长度为 <code>n</code> 的整数 <strong>山脉 </strong>数组 <code>arr</code> ,其中的值递增到一个 <strong>峰值元素</strong> 然后递减。</p>
|
||
|
||
<p>返回峰值元素的下标。</p>
|
||
|
||
<p>你必须设计并实现时间复杂度为 <code>O(log(n))</code> 的解决方案。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [0,1,0]
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [0,2,1,0]
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [0,10,5,2]
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>3 <= arr.length <= 10<sup>5</sup></code></li>
|
||
<li><code>0 <= arr[i] <= 10<sup>6</sup></code></li>
|
||
<li>题目数据 <strong>保证</strong> <code>arr</code> 是一个山脉数组</li>
|
||
</ul>
|