The One Without a Twin
nums is sorted in non-decreasing order. Every value appears exactly twice, except for one value that appears once. Return that value.
Aim for a binary search: there is no need to look at every item.
Example 1
nums [1,1,4,4,7,9,9]
returns 7
The 1s, 4s and 9s come in pairs. Only 7 stands alone.
Example 2
nums [3,5,5]
returns 3
The single value can be the very first item.
Example 3
nums [8]
returns 8
A list of one item has nothing but the single value.
Constraints
1 <= len(nums) <= 301, and the length is odd-109 <= nums[i] <= 109
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.