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

Difficulty: MEDIUM_HARD
Tags: Complete search
Skill types: Complete search

Starter code:
class Solution:
    def sequentialDigits(self, low: int, high: int) -> List[int]:
        

Solutions:
class Solution:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		l = len(str(low))
		f = len(str(high))
		s = len(str(low)[0])
		a = []
		for i in range(l, f + 1):
			while True:
				t = ''
				if i + s > 10:
					break
				for j in range(s, i + s):
					t += str(j)
				if int(t) > high:
					break
				if int(t) < low:
					s += 1
					continue
				s += 1
				a.append(t)
			s = 1
		return a


class Solution:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		nums = []
		max_digits = 9
		for depth in range(2, max_digits + 1):
			nums += self.genNum(max_digits, depth)
		return [n for n in nums if n >= low and n <= high]

	def genNum(self, max_digits, depth):
		result = []
		for startDigit in range(1, max_digits - depth + 2):
			num = startDigit
			for lvl in range(depth - 1):
				num = num * 10 + num % 10 + 1
			result.append(num)
		return result


class Solution:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		res = []

		def dfs(curr_num):
			if curr_num >= low and curr_num <= high:
				res.append(curr_num)
			elif curr_num > high:
				return
			if int(str(curr_num)[-1]) == 9:
				return
			dfs(curr_num * 10 + int(str(curr_num)[-1]) + 1)
		dfs(1)
		dfs(2)
		dfs(3)
		dfs(4)
		dfs(5)
		dfs(6)
		dfs(7)
		dfs(8)
		dfs(9)
		return sorted(res)


class Solution0:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		(nl, nh) = (len(str(low)), len(str(high)))
		ans = []
		sequential = '123456789'
		for n in range(nl, min(nh + 1, 10)):
			(start, delta) = (int(sequential[:n]), int('1' * n))
			k_min = 0 if n > nl else max(-(-(low - start) // delta), 0)
			k_max = 9 - n if n < nh else (min(high, int(sequential[-n:])) - start) // delta
			ans += [start + k * delta for k in range(k_min, k_max + 1)]
		return ans

class Solution:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		(nl, nh) = (len(str(low)), len(str(high)))
		ans = []
		sequential = '123456789'
		for n in range(nl, min(nh + 1, 10)):
			for k in range(10 - n):
				if low <= int(sequential[k:k + n]) <= high:
					ans.append(int(sequential[k:k + n]))
		return ans


class Solution:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		minRange = len(str(low))
		maxRange = len(str(high))
		digits = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		result = []
		for n in range(minRange, maxRange + 1):
			for i in range(10 - n):
				num = int(''.join(digits[i:i + n]))
				if num >= low and num <= high:
					result.append(num)
				if num > high:
					break
		return result


class Solution:

	def sequentialDigits(self, low: int, high: int) -> List[int]:
		ans = []
		for ndigit in range(1, 10):
			for i in range(1, 10 - ndigit + 1):
				x = i
				for j in range(ndigit - 1):
					x = x * 10 + (i + j + 1)
				if x > high:
					break
				if x >= low:
					ans.append(x)
		return ans


class Solution:

	def SequentialDigits(self, low: int, high: int) -> List[int]:
		res = []
		for i in range(1, 10):
			for j in range(i + 1, 10):
				i = i * 10 + j
				if i > high:
					break
				if i >= low:
					res.append(i)
		return sorted(res)

	def sequentialDigits(self, low, high):
		out = []
		queue = deque(range(1, 10))
		while queue and queue[0] <= high:
			elem = queue.popleft()
			if low <= elem:
				out.append(elem)
			last = elem % 10
			if last < 9:
				queue.append(elem * 10 + last + 1)
		return out