Medium

Quiz

#540 Single Element in a Sorted Array

APPROACH

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
1 of 4
1:00

What is the optimal approach for this problem?