mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 03:11:42 +08:00
批量更新数据
This commit is contained in:
@@ -1,38 +1,27 @@
|
||||
<p>(这是一个 <strong>交互式问题 </strong>)</p>
|
||||
|
||||
<p>给你一个 <strong>山脉数组</strong> <code>mountainArr</code>,请你返回能够使得 <code>mountainArr.get(index)</code> <strong>等于</strong> <code>target</code> <strong>最小</strong> 的下标 <code>index</code> 值。</p>
|
||||
|
||||
<p>如果不存在这样的下标 <code>index</code>,就请返回 <code>-1</code>。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>何为山脉数组?如果数组 <code>A</code> 是一个山脉数组的话,那它满足如下条件:</p>
|
||||
|
||||
<p><strong>首先</strong>,<code>A.length >= 3</code></p>
|
||||
|
||||
<p><strong>其次</strong>,在 <code>0 < i < A.length - 1</code> 条件下,存在 <code>i</code> 使得:</p>
|
||||
<p>你可以将一个数组 <code>arr</code> 称为 <strong>山脉数组 </strong>当且仅当:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>A[0] < A[1] < ... A[i-1] < A[i]</code></li>
|
||||
<li><code>A[i] > A[i+1] > ... > A[A.length - 1]</code></li>
|
||||
<li><code>arr.length >= 3</code></li>
|
||||
<li>存在一些 <code>0 < i < arr.length - 1</code> 的 <code>i</code> 使得:
|
||||
<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> </p>
|
||||
<p>给定一个山脉数组 <code>mountainArr</code> ,返回 <strong>最小</strong> 的 <code>index</code> 使得 <code>mountainArr.get(index) == target</code>。如果不存在这样的 <code>index</code>,返回 <code>-1</code> 。</p>
|
||||
|
||||
<p>你将 <strong>不能直接访问该山脉数组</strong>,必须通过 <code>MountainArray</code> 接口来获取数据:</p>
|
||||
<p><strong>你无法直接访问山脉数组</strong>。你只能使用 <code>MountainArray</code> 接口来访问数组:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>MountainArray.get(k)</code> - 会返回数组中索引为<code>k</code> 的元素(下标从 0 开始)</li>
|
||||
<li><code>MountainArray.length()</code> - 会返回该数组的长度</li>
|
||||
<li><code>MountainArray.get(k)</code> 返回数组中下标为 <code>k</code> 的元素(从 0 开始)。</li>
|
||||
<li><code>MountainArray.length()</code> 返回数组的长度。</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>注意:</strong></p>
|
||||
|
||||
<p>对 <code>MountainArray.get</code> 发起超过 <code>100</code> 次调用的提交将被视为错误答案。此外,任何试图规避判题系统的解决方案都将会导致比赛资格被取消。</p>
|
||||
|
||||
<p>为了帮助大家更好地理解交互式问题,我们准备了一个样例 “<strong>答案</strong>”:<a href="https://leetcode-cn.com/playground/RKhe3ave" target="_blank">https://leetcode-cn.com/playground/RKhe3ave</a>,请注意这 <strong>不是一个正确答案</strong>。</p>
|
||||
<p>调用 <code>MountainArray.get</code> 超过 <code>100</code> 次的提交会被判定为错误答案。此外,任何试图绕过在线评测的解决方案都将导致取消资格。</p>
|
||||
|
||||
<ol>
|
||||
</ol>
|
||||
@@ -41,13 +30,15 @@
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>array = [1,2,3,4,5,3,1], target = 3
|
||||
<pre>
|
||||
<strong>输入:</strong>mountainArr = [1,2,3,4,5,3,1], target = 3
|
||||
<strong>输出:</strong>2
|
||||
<strong>解释:</strong>3 在数组中出现了两次,下标分别为 2 和 5,我们返回最小的下标 2。</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>array = [0,1,2,4,2,1], target = 3
|
||||
<pre>
|
||||
<strong>输入:</strong>mountainArr = [0,1,2,4,2,1], target = 3
|
||||
<strong>输出:</strong>-1
|
||||
<strong>解释:</strong>3 在数组中没有出现,返回 -1。
|
||||
</pre>
|
||||
@@ -57,7 +48,7 @@
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>3 <= mountain_arr.length() <= 10000</code></li>
|
||||
<li><code>0 <= target <= 10^9</code></li>
|
||||
<li><code>0 <= mountain_arr.get(index) <= 10^9</code></li>
|
||||
<li><code>3 <= mountainArr.length() <= 10<sup>4</sup></code></li>
|
||||
<li><code>0 <= target <= 10<sup>9</sup></code></li>
|
||||
<li><code>0 <= mountainArr.get(index) <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user