#540
Single Element in a Sorted Array
specialist · 720 · lc medium +30 · verified · 59.2% accepted · 12,911 likes · top 56%
Description
In a sorted integer array every value appears exactly twice except for one unique value that appears only once. Find and return that unique element. Your solution must achieve O(log n) time and O(1) space.
Example 1:
Input: nums = [1,1,2,3,3,4,4,8,8]
Output: 2
Example 2:
Input: nums = [3,3,7,7,10,11,11]
Output: 10
Code
1
2
3