Leetcode 1212 Solution
This article provides solution to leetcode question 1212 (sequential-digits)
Access this page by simply typing in "lcs 1212" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/sequential-digits
Solution
class Solution:
def sequentialDigits(self, low: int, high: int) -> List[int]:
ans = []
for i in range(1, 10):
j = i
curr_num = str(j)
while int(curr_num) <= high:
if int(curr_num) >= low:
ans.append(int(curr_num))
if j == 9:
break
j += 1
curr_num += str(j)
return sorted(ans)