Trains the technique from
LeetCode 632Smallest Range Covering Elements from K ListsThis 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 field survey runs k gauges. Gauge i filed the readings in nums[i],
already arranged from lowest to highest, and every gauge filed at least one
reading.
Calibration needs a single band of values that reaches every gauge. A band is
written [low, high] with low <= high, and it reaches a gauge when at least
one of that gauge's readings sits inside the band, endpoints included.
Return the tightest band that reaches all k gauges. Tightest means the
smallest high - low. When several bands tie on that width, return the one
whose low is smallest.
Example 1
The band [9,13] holds 11 from the first gauge, 13 from the second and 9 from the third, so it reaches all three and its width is 4.
Example 2
Three bands reach both gauges at width 2: [1,3], [3,5] and [5,7]. The tie goes to the smallest low, so the answer is [1,3].
Example 3
With one gauge and one reading, the band [8,8] already reaches it and has width 0.
Example 4
The second gauge only ever reads 0, so a band must stretch from 0 to one of -100000 or 100000. Both give width 100000, and the smaller low wins.
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 smallest_range(nums: list[list[int]]) -> list[int]:public int[] smallestRange(List<List<Integer>> nums)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.