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.
Example 1:
Input: low = 100, high = 300
Output: [123,234]
Example 2:
Input: low = 1000, high = 13000
Output: [1234,2345,3456,4567,5678,6789,12345]
Constraints:
10 <= low <= high <= 10^9
這題給我們兩個變數,low 與 high。
題目需要我們在 low - high 區間裡面找到符合條件的整數,
條件是這個整數必須每一位都比前一位大"1"。
這題如果沒有那個條件,會非常難做,
要考慮 low, high 不同位數。
但如果有遞增"1",可以視為 "123456789" 的模板來做,
另外要注意 substr 的用法是填入起始位元與長度,
這個起始位元需要被計算進來,所以邊界條件要 l + ls <= 9。
C++程式碼: