Skip to content

Latest commit

 

History

History
93 lines (38 loc) · 1.48 KB

File metadata and controls

93 lines (38 loc) · 1.48 KB

中文文档

Description

Let's call an array A a mountain if the following properties hold:

    <li><code>A.length &gt;= 3</code></li>
    
    <li>There exists some <code>0 &lt; i&nbsp;&lt; A.length - 1</code> such that <code>A[0] &lt; A[1] &lt; ... A[i-1] &lt; A[i] &gt; A[i+1] &gt; ... &gt; A[A.length - 1]</code></li>
    

Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1].

Example 1:

Input: [0,1,0]

Output: 1

Example 2:

Input: [0,2,1,0]

Output: 1

Note:

    <li><code>3 &lt;= A.length &lt;= 10000</code></li>
    
    <li><code><font face="monospace">0 &lt;= A[i] &lt;= 10^6</font></code></li>
    
    <li>A&nbsp;is a mountain, as defined above.</li>
    

Solutions

Python3

Java

...