> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Sequential Digits Python Solution with Tests

> Tested Python solution for LeetCode 1291 with 12 pytest cases. Generate a practice environment with lcpy.

LeetCode 1291, [Medium](/catalog/medium). Topics: [Enumeration](/catalog/topics/enumeration). [View on LeetCode](https://leetcode.com/problems/sequential-digits/description/).

Generate this problem as a practice environment: tested reference solution, 12 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 1291   # by problem number
lcpy gen -s sequential_digits   # by problem name
```

## Problem

An integer has sequential digits if and only if each digit in the number is one more than the previous digit.

Return a sorted list of all the integers in the range \[low, high] inclusive that have sequential digits.

### Examples

```
Input: low = 100, high = 300
Output: [123,234]
```

```
Input: low = 1000, high = 13000
Output: [1234,2345,3456,4567,5678,6789,12345]
```

### Constraints

* 10 \<= low \<= high \<= 10^9

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sequential_digits/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sequential_digits/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
class Solution:
    def sequential_digits(self, low: int, high: int) -> list[int]:
        result: list[int] = []
        for length in range(2, 10):
            for start in range(1, 11 - length):
                num = int("".join(str(start + i) for i in range(length)))
                if low <= num <= high:
                    result.append(num)
        return result
```

## Complexity

| Time | Space |
| - | - |
| - | - |

## Tags

[NeetCode All](/catalog/neetcode).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.