Generate all integers in a range whose digits form consecutive increasing sequences.
Sequential Digits
gfgGiven two integers low and high, return all integers in the inclusive range [low, high] such that every digit in the number is exactly one greater than the previous digit.
A number like 1234 is sequential, while 135 or 1223 is not.
Return the results in increasing order.
Input Format
- Two integers
lowandhigh. - Find every integer
xsuch thatlow <= x <= highand the digits ofxare strictly consecutive increasing by 1.
Output Format
- Return a list of all valid integers in ascending order.
Constraints
10 <= low <= high <= $10^{9}$- Each valid number must use digits from
1to9without repetition. - The answer size is finite and small because sequential numbers can only be formed from contiguous digit runs.
Example 1
Input
low = 100, high = 300
Output
[123,234]
Explanation
The sequential-digit numbers in this range are 123 and 234.
Example 2
Input
low = 1000, high = 13000
Output
[1234,2345,3456,4567,5678,6789,12345]
Explanation
Each number is made of consecutive increasing digits and falls within the range.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.