> For the complete documentation index, see [llms.txt](https://hao-fu-1.gitbook.io/oj/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hao-fu-1.gitbook.io/oj/array_and_numbers/1291.-sequential-digits.md).

# 1291. Sequential Digits

https\://leetcode.com/problems/sequential-digits/

按序找到\[low, high]内所有digit满足递增的数。这样的数在整数范围内一共也就常数个，可以都列出来。也可以用BFS或string操作的方式把所有的可能遍历出来。

```cpp
class Solution {
public:
    vector<int> sequentialDigits(int low, int high) {
        queue<int> q;
        for (int i = 1; i <= 9; ++i) q.push(i);
        vector<int> res;
        while (!q.empty()) {
            auto t = q.front(); q.pop();
            if (t > high) break;
            if (t >= low && t <= high) {
                res.push_back(t);
            }
            if (t % 10 == 9) continue;
            q.push(t * 10 + t % 10 + 1);
        }
        return res;
    }
};
```
