Trains the technique from
LeetCode 136Single NumberThis 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.
Two surveyors walk the same stretch of track and file signed elevation corrections in centimetres, negative where the bed sits below the design line. Any correction that truly belongs on the sheet gets filed by both of them, so it shows up on the combined sheet twice. Exactly one correction was filed by a single surveyor, so it shows up there just once.
You are handed the combined sheet as the array corrections, in filing order. Report the value of the correction that shows up only once.
The sheet can run long, so settle it in one sweep over the entries while holding only a fixed amount of extra memory: no tally table, no second copy of the sheet, no reordering.
Example 1
Both -14 and 6 were filed by each surveyor, leaving 25 as the correction only one of them filed.
Example 2
A correction of zero is a real filing, and here it is the one that shows up a single time.
Example 3
A sheet with a single entry can only be the lone filing, so it is reported as is.
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 unpaired_correction(corrections: list[int]) -> int:public int unpairedCorrection(int[] corrections)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.