Baseline Binary Search · 1D Arrays O(log n) · O(1)
A sensor row registers readings in sorted order where every model appears exactly twice - once for the primary unit and once for its standby - except one model whose standby was never commissioned. The maintenance query must find that lone model using only logarithmic probes over the sorted row.
Input: An array nums of n integers, sorted in non-decreasing order, where exactly one value appears once and every other value appears exactly twice.
Output: The value that appears exactly once.
1 <= n <= 10^50 <= nums[i] <= 10^5n is oddAn O(log n) algorithm with O(1) space is requiredInput: {"nums":[1,1,2,3,3,4,4,8,8]}
Output: 2
Every pairing survives until the lone 2, which breaks the alternating twos pattern.
Input: {"nums":[3,3,7,7,10,11,11]}
Output: 10
The pairing pattern stays intact left of 10 and collapses right of it, isolating the unpaired beacon.