1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-12 17:05:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -1,19 +1,21 @@
<p>魔术索引。 在数组<code>A[0...n-1]</code>中,有所谓的魔术索引,满足条件<code>A[i] = i</code>。给定一个有序整数数组编写一种方法找出魔术索引若有的话在数组A中找出一个魔术索引如果没有则返回-1。若有多个魔术索引返回索引值最小的一个。</p>
<p><strong>示例1:</strong></p>
<p><strong>示例 1</strong></p>
<pre><strong> 输入</strong>nums = [0, 2, 3, 4, 5]
<pre>
<strong> 输入</strong>nums = [0, 2, 3, 4, 5]
<strong> 输出</strong>0
<strong> 说明</strong>: 0下标的元素为0
<strong> 说明</strong>0下标的元素为0
</pre>
<p><strong>示例2:</strong></p>
<p><strong>示例 2</strong></p>
<pre><strong> 输入</strong>nums = [1, 1, 1]
<pre>
<strong> 输入</strong>nums = [1, 1, 1]
<strong> 输出</strong>1
</pre>
<p><strong>说明:</strong></p>
<p><strong>说明</strong></p>
<ol>
<li>nums长度在[1, 1000000]之间</li>