Trains the technique from
LeetCode 4Median of Two Sorted ArraysThis 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 weather stations each keep a log of temperature readings in whole degrees, and each log already runs from coldest to warmest. north holds one station's log, south holds the other's. A reading may repeat inside a log, readings may fall below zero, and one of the two logs may hold nothing at all, though not both at once.
Picture every reading from both logs poured into one shared line-up, still ordered coldest to warmest. Return the value standing at the centre of that line-up, as a decimal. When the shared line-up holds an even count there are two values at the centre, and the answer is their mean.
Pouring the two logs together is off limits, and so is ordering them again. Instead, settle the answer by halving the range of candidate cut points inside the shorter log, so the work grows with the logarithm of the shorter log's length.
Example 1
The shared line-up reads 1, 2, 3, 10. Four readings put two of them at the centre, 2 and 3, whose mean is 2.5.
Example 2
The shared line-up reads -3, -2, -1, 5, 6. Five readings leave a single centre, the third one.
Example 3
One station reported nothing, so the other log is the whole line-up and its middle reading answers on its own.
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 paired_station_median(north: list[int], south: list[int]) -> float:public double pairedStationMedian(int[] north, int[] south)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.