Skip to content

Commit cb3a098

Browse files
committed
Create README - LeetHub
1 parent 4ad6a8d commit cb3a098

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<h2>852. Peak Index in a Mountain Array</h2><h3>Easy</h3><hr><div><p>Let's call an array <code>arr</code> a <strong>mountain</strong>&nbsp;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&nbsp;<code>0 &lt; i&nbsp;&lt; arr.length - 1</code>&nbsp;such that:
6+
<ul>
7+
<li><code>arr[0] &lt; arr[1] &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 an integer array <code>arr</code> that is <strong>guaranteed</strong> to be&nbsp;a mountain, return any&nbsp;<code>i</code>&nbsp;such that&nbsp;<code>arr[0] &lt; arr[1] &lt; ... arr[i - 1] &lt; arr[i] &gt; arr[i + 1] &gt; ... &gt; arr[arr.length - 1]</code>.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong>Example 1:</strong></p>
17+
<pre><strong>Input:</strong> arr = [0,1,0]
18+
<strong>Output:</strong> 1
19+
</pre><p><strong>Example 2:</strong></p>
20+
<pre><strong>Input:</strong> arr = [0,2,1,0]
21+
<strong>Output:</strong> 1
22+
</pre><p><strong>Example 3:</strong></p>
23+
<pre><strong>Input:</strong> arr = [0,10,5,2]
24+
<strong>Output:</strong> 1
25+
</pre><p><strong>Example 4:</strong></p>
26+
<pre><strong>Input:</strong> arr = [3,4,5,1]
27+
<strong>Output:</strong> 2
28+
</pre><p><strong>Example 5:</strong></p>
29+
<pre><strong>Input:</strong> arr = [24,69,100,99,79,78,67,36,26,19]
30+
<strong>Output:</strong> 2
31+
</pre>
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li><code>3 &lt;= arr.length &lt;= 10<sup>4</sup></code></li>
37+
<li><code>0 &lt;= arr[i] &lt;= 10<sup>6</sup></code></li>
38+
<li><code>arr</code> is <strong>guaranteed</strong> to be a mountain array.</li>
39+
</ul>
40+
41+
<p>&nbsp;</p>
42+
<strong>Follow up:</strong> Finding the <code>O(n)</code> is straightforward, could you find an <code>O(log(n))</code> solution?</div>

0 commit comments

Comments
 (0)