<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>&nbsp;</p>
<p><strong class="example">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 class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> nums = [3,3,7,7,10,11,11]
<strong>Output:</strong> 10
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
	<li><code>0 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

'''
Since every element appears twice except for one, we know the array is always odd
Let's draw this out to see any relationship with their index.

[3,3,7,7,10,11,11]

[0,1,2,3,4,5,6] index

-single number always on the an even index %2==0.
-first number of every double elements:
    -on the left side, they start on an even index
    -on the right side, they start on an odd index
This means if we land on the left, we can add 2 to get to the next left?
'''
class Solution:
    def singleNonDuplicate(self, nums: List[int]) -> int:
        l, r = 0, len(nums)-1

        while l<r:
            mid = l + (r-l)//2
            print(mid)
            if mid%2: #odd
                #check which side we landed on
                if nums[mid] == nums[mid-1]: #right side
                    l = mid+1
                else:
                    r = mid
            else: #even
                if nums[mid] == nums[mid+1]: #right side
                    l = mid+1
                else:
                    r = mid
        
        return nums[l]
26200