1291. Sequential Digits

1291. Sequential Digits

python 复制代码
class Solution:
    def sequentialDigits(self, low: int, high: int) -> List[int]:
        ans=[]
        for i in range(1,10):
            num=i
            nt_digit=i+1
            while num<high and nt_digit<=9:
                num=num*10+nt_digit
                if low<=num and num<=high:
                    ans.append(num)
                nt_digit+=1
        return sorted(ans)

模拟

相关推荐
mifengxing4 小时前
LeetCode 41.缺失的第一个正数|Hard题O(n)+O(1)最优解法深度解析
java·算法·leetcode·排序算法
hanlin039 小时前
动态规划专练:力扣第121、122题
笔记·算法·leetcode
To_OC9 小时前
LC 74 搜索二维矩阵:换皮的二分查找,我居然一开始没看出来
javascript·算法·leetcode
玖玥拾9 小时前
LeetCode 189 轮转数组
算法·leetcode
Tisfy12 小时前
LeetCode 3345.最小可整除数位乘积 I:暴力枚举(从n开始尝试)
数学·算法·leetcode·题解·枚举
青山木13 小时前
Hot 100 --- 在排序数组中查找元素的第一个和最后一个位置
java·数据结构·算法·leetcode
mifengxing14 小时前
LeetCode 238 除自身以外数组的乘积|无除法O(n)时间+O(1)空间双解法
java·算法·leetcode
无bug代码搬运工16 小时前
LeetCode 42 接雨水:双指针解法详解
算法·leetcode·职场和发展
zander25820 小时前
34. 在排序数组中查找元素的第一个和最后一个位置:用两个边界定位区间
数据结构·算法·leetcode
To_OC1 天前
LC 35 搜索插入位置:二分查找谁都会,边界条件谁写谁懵
javascript·算法·leetcode