Trains the technique from
LeetCode 1200Minimum Absolute DifferenceThis 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 bench measures a batch of gauges against a reference block and records readings, the signed offset in micrometres that each gauge showed. The readings come in the order the gauges were measured, which is not necessarily sorted, and no two gauges showed the same offset.
Call the tightest gap the smallest difference between two of the recorded offsets.
Return every pair of offsets whose difference equals the tightest gap. Write each pair as [lower, higher] and list the pairs by their lower offset, smallest first. No two reported pairs share a lower offset, so that order is unambiguous.
Example 1
The tightest gap is 1 micrometre, and two pairs of offsets sit that close: 3 with 4, and 8 with 9. The pair with the lower first offset is listed first.
Example 2
The tightest gap is 2 micrometres, reached by -9 with -7 and by -2 with 0.
Example 3
Two gauges leave a single pair, whose difference of 10 micrometres is therefore the tightest gap.
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 tightest_gaps(readings: list[int]) -> list[list[int]]:public List<List<Integer>> tightestGaps(int[] readings)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.