Trains the technique from
LeetCode 540Single Element in a Sorted ArrayThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A repair depot stocks components in matched pairs, one for the machine and one held as a spare, and both members of a pair carry the same serial. The stock sheet serials lists the serial of every component on the shelf in non-decreasing order.
One component arrived without its twin, so exactly one serial appears once on the sheet while every other serial appears twice. Return the serial of that unmatched component.
The sheet can be very long, so your routine must finish in O(log n) time and use O(1) extra space.
Example 1
Serials 4, 12 and 19 each sit on the shelf twice, and 23 sits at the far end on its own.
Example 2
The unmatched component opens the sheet, so every pair after it starts at an odd position.
Example 3
The pair 2, 2 sits before the loose component and the pair 15, 15 sits after it.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def unmatched_serial(serials: list[int]) -> int:public int unmatchedSerial(int[] serials)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.