Skip to content

Commit 2b093a6

Browse files
committed
Create README - LeetHub
1 parent 175d615 commit 2b093a6

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<h2><a href="https://leetcode.com/problems/peak-index-in-a-mountain-array">882. Peak Index in a Mountain Array</a></h2><h3>Medium</h3><hr><p>An array <code>arr</code> is a <strong>mountain</strong> if the following properties hold:</p>
2+
3+
<ul>
4+
<li><code>arr.length &gt;= 3</code></li>
5+
<li>There exists some <code>i</code> with <code>0 &lt; i &lt; arr.length - 1</code> such that:
6+
<ul>
7+
<li><code>arr[0] &lt; arr[1] &lt; ... &lt; arr[i - 1] &lt; arr[i] </code></li>
8+
<li><code>arr[i] &gt; arr[i + 1] &gt; ... &gt; arr[arr.length - 1]</code></li>
9+
</ul>
10+
</li>
11+
</ul>
12+
13+
<p>Given a mountain array <code>arr</code>, return the index <code>i</code> such that <code>arr[0] &lt; arr[1] &lt; ... &lt; arr[i - 1] &lt; arr[i] &gt; arr[i + 1] &gt; ... &gt; arr[arr.length - 1]</code>.</p>
14+
15+
<p>You must solve it in <code>O(log(arr.length))</code> time complexity.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong class="example">Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> arr = [0,1,0]
22+
<strong>Output:</strong> 1
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> arr = [0,2,1,0]
29+
<strong>Output:</strong> 1
30+
</pre>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> arr = [0,10,5,2]
36+
<strong>Output:</strong> 1
37+
</pre>
38+
39+
<p>&nbsp;</p>
40+
<p><strong>Constraints:</strong></p>
41+
42+
<ul>
43+
<li><code>3 &lt;= arr.length &lt;= 10<sup>5</sup></code></li>
44+
<li><code>0 &lt;= arr[i] &lt;= 10<sup>6</sup></code></li>
45+
<li><code>arr</code> is <strong>guaranteed</strong> to be a mountain array.</li>
46+
</ul>

0 commit comments

Comments
 (0)