Trains the technique from
LeetCode 4026Maximum Gap Between StationsThis 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.
Workers are lined up in the order given by skill, one letter each, and benches are lined up in the order given by station, one letter each. There are at least as many benches as workers.
Each worker is put on a bench whose letter matches their own, one worker per bench, and the workers keep their order: an earlier worker must take an earlier bench. At least one such assignment is guaranteed to exist.
The step between two neighbouring workers is the difference between their bench positions. Return the widest step any assignment can have, or 0 when there is only one worker.
Example 1
The worker wanting an a can take bench 0 and the one wanting a b can take bench 3, which is as far apart as they go.
Example 2
With a single worker there is no neighbouring pair to measure.
Example 3
Each worker has exactly one bench that matches, so the step is fixed at one.
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 maximum_gap(skill: str, station: str) -> int:public int maximumGap(String skill, String station)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.