Binary Search on Pairs - Find the Unique Element
In an array where every element appears twice except one unique element, we can find the lone warrior using binary search!
Key Insight:
(0,1), (2,3), (4,5)...
(5,6), (7,8)...
mid is even, check
arr[mid] == arr[mid+1]; if equal, unique is on right
mid is odd, check
arr[mid] == arr[mid-1]; if equal, unique is on right