LeetCode 1215, Medium. Topics: Breadth-First Search, Math, Backtracking. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 21 parametrized pytest cases, and a playground notebook:
Problem
A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1.
- For example,
321 is a stepping number while 421 is not.
Given two integers low and high, return a sorted list of all the stepping numbers in the inclusive range [low, high].
Examples
Constraints
0 <= low <= high <= 2 * 10^9
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026