mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
22 lines
766 B
HTML
22 lines
766 B
HTML
<p>You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.</p>
|
|
|
|
<p>Return <em>the single element that appears only once</em>.</p>
|
|
|
|
<p>Your solution must run in <code>O(log n)</code> time and <code>O(1)</code> space.</p>
|
|
|
|
<p> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
<pre><strong>Input:</strong> nums = [1,1,2,3,3,4,4,8,8]
|
|
<strong>Output:</strong> 2
|
|
</pre><p><strong>Example 2:</strong></p>
|
|
<pre><strong>Input:</strong> nums = [3,3,7,7,10,11,11]
|
|
<strong>Output:</strong> 10
|
|
</pre>
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
|
|
<li><code>0 <= nums[i] <= 10<sup>5</sup></code></li>
|
|
</ul>
|