Trains the technique from
LeetCode 1291Sequential DigitsThis 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 parts catalogue reserves a special shape of serial number for its display models. A staircase serial is a positive integer of two or more digits in which each digit is exactly one more than the digit to its left. 45, 678 and 23456 are staircase serials; 55, 321 and 1357 are not, and neither is anything containing a 0, since no digit is one more than 9.
Given an inclusive window [low, high], return every staircase serial that falls inside it, listed from smallest to largest. Return an empty list when the window holds none.
Example 1
Six four-digit staircase serials sit inside the window, and 12345 is the only five-digit one below 13000.
Example 2
The lower end of the window is itself a staircase serial and so counts; 6789 is the only other one before the window closes.
Example 3
The three-digit serials of this shape are 123 and up, so nothing in the window qualifies and the list comes back empty.
Example 4
The window is a single value and 5 is one more than 4, so that value is the whole answer.
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 staircase_serials(low: int, high: int) -> list[int]:public List<Integer> staircaseSerials(int low, int high)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.