Quant Memo
Coding/●●●●●

The single element in a paired sorted array

Asked at Two Sigma

A sorted array has every element appearing exactly twice, except one element that appears once. The duplicate pairs sit next to each other.

a = [1, 1, 2, 3, 3, 4, 4, 8, 8]     -> 2
a = [3, 3, 7, 7, 10, 11, 11]        -> 10
a = [5]                             -> 5

Return the single element. Aim for O(logn)O(\log n).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions