Trains the technique from
LeetCode 2007Find Original Array From Doubled 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 calibration rig measures a batch of samples. For every sample the rig prints two rows on one sheet: the sample's base reading, and a second row holding exactly twice that base reading. A base reading of 0 therefore prints two rows of 0. The sheet then went through a shredder and was reassembled in some arbitrary order, giving the list sheet.
Work out the base readings the rig measured and return them in ascending order. If no set of base readings could have printed sheet — including the case where sheet holds an odd number of rows — return an empty list.
Example 1
Base reading 1 printed the rows 1 and 2, and base reading 3 printed the rows 3 and 6. Together those four rows are exactly the sheet, so the base readings are reported ascending.
Example 2
Base reading 0 printed two rows of 0, and base reading 3 printed the rows 3 and 6.
Example 3
There is no set of three base readings whose printed rows come to this sheet, so the empty list is returned.
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 recover_base_readings(sheet: list[int]) -> list[int]:public int[] recoverBaseReadings(int[] sheet)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.