Single Element in a Sorted Array

Medium · Binary Search · about 15 minutes

Asked at Bloomberg, Amazon, Microsoft, Meta, Google.

nums is sorted, and every value in it occurs twice, except for one value that occurs only once. Return that lone value using O(log n) time and O(1) extra memory.

Related guides