mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 19:01:47 +08:00
批量更新数据
This commit is contained in:
@@ -1,40 +1,33 @@
|
||||
<p>An array <code>arr</code> is a <strong>mountain</strong> if the following properties hold:</p>
|
||||
<p>You are given an integer <strong>mountain</strong> array <code>arr</code> of length <code>n</code> where the values increase to a <strong>peak element</strong> and then decrease.</p>
|
||||
|
||||
<ul>
|
||||
<li><code>arr.length >= 3</code></li>
|
||||
<li>There exists some <code>i</code> with <code>0 < i < arr.length - 1</code> such that:
|
||||
<ul>
|
||||
<li><code>arr[0] < arr[1] < ... < arr[i - 1] < arr[i] </code></li>
|
||||
<li><code>arr[i] > arr[i + 1] > ... > arr[arr.length - 1]</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Return the index of the peak element.</p>
|
||||
|
||||
<p>Given a mountain array <code>arr</code>, return the index <code>i</code> such that <code>arr[0] < arr[1] < ... < arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - 1]</code>.</p>
|
||||
|
||||
<p>You must solve it in <code>O(log(arr.length))</code> time complexity.</p>
|
||||
<p>Your task is to solve it in <code>O(log(n))</code> time complexity.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> arr = [0,1,0]
|
||||
<strong>Output:</strong> 1
|
||||
</pre>
|
||||
<div class="example-block">
|
||||
<p><strong>Input:</strong> <span class="example-io">arr = [0,1,0]</span></p>
|
||||
|
||||
<p><strong>Output:</strong> <span class="example-io">1</span></p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> arr = [0,2,1,0]
|
||||
<strong>Output:</strong> 1
|
||||
</pre>
|
||||
<div class="example-block">
|
||||
<p><strong>Input:</strong> <span class="example-io">arr = [0,2,1,0]</span></p>
|
||||
|
||||
<p><strong>Output:</strong> <span class="example-io">1</span></p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> arr = [0,10,5,2]
|
||||
<strong>Output:</strong> 1
|
||||
</pre>
|
||||
<div class="example-block">
|
||||
<p><strong>Input:</strong> <span class="example-io">arr = [0,10,5,2]</span></p>
|
||||
|
||||
<p><strong>Output:</strong> <span class="example-io">1</span></p>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
Reference in New Issue
Block a user