代码拉取完成,页面将自动刷新
<p><em>(This problem is an <strong>interactive problem</strong>.)</em></p>
<p>You may recall that an array <code>arr</code> is a <strong>mountain array</strong> if and only if:</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>Given a mountain array <code>mountainArr</code>, return the <strong>minimum</strong> <code>index</code> such that <code>mountainArr.get(index) == target</code>. If such an <code>index</code> does not exist, return <code>-1</code>.</p>
<p><strong>You cannot access the mountain array directly.</strong> You may only access the array using a <code>MountainArray</code> interface:</p>
<ul>
<li><code>MountainArray.get(k)</code> returns the element of the array at index <code>k</code> (0-indexed).</li>
<li><code>MountainArray.length()</code> returns the length of the array.</li>
</ul>
<p>Submissions making more than <code>100</code> calls to <code>MountainArray.get</code> will be judged <em>Wrong Answer</em>. Also, any solutions that attempt to circumvent the judge will result in disqualification.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> array = [1,2,3,4,5,3,1], target = 3
<strong>Output:</strong> 2
<strong>Explanation:</strong> 3 exists in the array, at index=2 and index=5. Return the minimum index, which is 2.</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> array = [0,1,2,4,2,1], target = 3
<strong>Output:</strong> -1
<strong>Explanation:</strong> 3 does not exist in <code>the array,</code> so we return -1.
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>3 <= mountain_arr.length() <= 10<sup>4</sup></code></li>
<li><code>0 <= target <= 10<sup>9</sup></code></li>
<li><code>0 <= mountain_arr.get(index) <= 10<sup>9</sup></code></li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。