|
| 1 | +<h2><ahref="https://leetcode.com/problems/single-element-in-a-sorted-array/">540. Single Element in a Sorted Array</a></h2><h3>Medium</h3><hr><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> |
| 2 | + |
| 3 | +<p>Return <em>the single element that appears only once</em>.</p> |
| 4 | + |
| 5 | +<p>Your solution must run in <code>O(log n)</code> time and <code>O(1)</code> space.</p> |
| 6 | + |
| 7 | +<p> </p> |
| 8 | +<p><strongclass="example">Example 1:</strong></p> |
| 9 | +<pre><strong>Input:</strong> nums = [1,1,2,3,3,4,4,8,8] |
| 10 | +<strong>Output:</strong> 2 |
| 11 | +</pre><p><strongclass="example">Example 2:</strong></p> |
| 12 | +<pre><strong>Input:</strong> nums = [3,3,7,7,10,11,11] |
| 13 | +<strong>Output:</strong> 10 |
| 14 | +</pre> |
| 15 | +<p> </p> |
| 16 | +<p><strong>Constraints:</strong></p> |
| 17 | + |
| 18 | +<ul> |
| 19 | +<li><code>1 <= nums.length <= 10<sup>5</sup></code></li> |
| 20 | +<li><code>0 <= nums[i] <= 10<sup>5</sup></code></li> |
| 21 | +</ul> |