Sequential Digits

An integer has sequential digits when each digit is exactly one more than the digit before it, like 123 or 6789. Given low and high, return a sorted list of every integer in [low, high] that has sequential digits.

30:00

Sequential Digits
medium
Free written solution
Topics
Companies

An integer has sequential digits when each digit is exactly one more than the digit before it, like 123 or 6789. Given low and high, return a sorted list of every integer in [low, high] that has sequential digits.

Example 1:
Input: {"low":100,"high":300}
Output: [123,234]
Constraints:
  • 10≤low≤high≤10910 \leq \text{low} \leq \text{high} \leq 10^9

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"low":100,"high":300}

Every sequential-digit number is a contiguous slice of "123456789". Slide windows over it and keep the slices inside [100, 300].

range [100, 300]
lengths 3..3

digits = "123456789"

1

0

2

1

3

2

4

3

5

4

6

5

7

6

8

7

9

8

low ≤ num ≤ high ?

candidates by length

3:

·

result (0)

[]
Variables
VariableValue
low100
high300
DepthFunction Call
Stack empty
0/18