题目描述:

自己的提交:

class Solution:
def sequentialDigits(self, low: int, high: int) -> List[int]:
l,h = len(str(low)),len(str(high))
res = []
def helper(num,length):
if length == 0 and low <= num <= high:
res.append(num)
return
if num % 10 == 9:
return
helper(num*10+(num%10+1),length-1)
for i in range(l,h+1):
for j in range(1,10):
helper(j,i-1)
return res

另:

class Solution:
def sequentialDigits(self, low: int, high: int) -> List[int]:
ans = list()
for i in range(1, 10):
num = i
for j in range(i + 1, 10):
num = num * 10 + j
if low <= num <= high:
ans.append(num)
return sorted(ans)

leetcode-167周赛-1291-顺次数的更多相关文章

  1. LeetCode 1291. 顺次数

    地址 https://leetcode-cn.com/problems/sequential-digits/submissions/ 题目描述我们定义「顺次数」为:每一位上的数字都比前一位上的数字大 ...

  2. 【Leetcode 滑动窗口】顺次数(1291)

    题目 我们定义「顺次数」为:每一位上的数字都比前一位上的数字大 1 的整数. 请你返回由 [low, high] 范围内所有顺次数组成的 有序 列表(从小到大排序).   示例 1: 输出:low = ...

  3. leetcode 167 two sum II

    167. Two Sum II - Input array is sorted Given an array of integers that is already sorted in ascendi ...

  4. [LeetCode] #167# Two Sum II : 数组/二分查找/双指针

    一. 题目 1. Two Sum II Given an array of integers that is already sorted in ascending order, find two n ...

  5. 29. leetcode 167. Two Sum II - Input array is sorted

    167. Two Sum II - Input array is sorted Given an array of integers that is already sorted in ascendi ...

  6. LeetCode 167. Two Sum II - Input array is sorted (两数之和之二 - 输入的是有序数组)

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

  7. 力扣(LeetCode)453. 最小移动次数使数组元素相等

    给定一个长度为 n 的非空整数数组,找到让数组所有元素相等的最小移动次数.每次移动可以使 n - 1 个元素增加 1. 示例: 输入: [1,2,3] 输出: 3 解释: 只需要3次移动(注意每次移动 ...

  8. leetcode 双周赛9 进击的骑士

    一个坐标可以从 -infinity 延伸到 +infinity 的 无限大的 棋盘上,你的 骑士 驻扎在坐标为 [0, 0] 的方格里. 骑士的走法和中国象棋中的马相似,走 “日” 字:即先向左(或右 ...

  9. LeetCode 167:两数之和 II - 输入有序数组 Two Sum II - Input array is sorted

    公众号: 爱写bug(ID:icodebugs) 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数. 函数应该返回这两个下标值 index1 和 index2,其中 index ...

  10. [LeetCode] 167. Two Sum II - Input array is sorted 两数和 II - 输入是有序的数组

    Given an array of integers that is already sorted in ascending order, find two numbers such that the ...

随机推荐

  1. ECSHOP2.7源码分析

    目录结构

  2. POI样式

    5.POI样式 在Excel应用中,会需要用到各种样式,包括单元格背景色.边框.高度.宽度.内容相对位置.字体格式.字体大小.字体颜色等等.POI提供了一系列的样式,能满足我们一般开发中的需求. 5. ...

  3. matplot在Mac下显示中文的方案

    使用matplotlib经常会出现中文显示异常的问题. 网上很多都讲需要下载中文字体包...偶然看到别人发的一种简单的解决放啊.Mac上本身就有支持中文的字体包啊.引入就好了 贴上代码 plt.rcP ...

  4. MySql常用语句总结更新

    1.Mysql修改字段的默认值: alter table tablename alter column drop default; (若本身存在默认值,则先删除) alter table tablen ...

  5. PostgreSQL 在视频、图片去重,图像搜索业务中的应用

    摘要: PostgreSQL 在视频.图片去重,图像搜索业务中的应用作者digoal日期2016-11-26标签PostgreSQL , Haar wavelet , 图像搜索 , 图片去重 , 视频 ...

  6. 【FICO系列】SAP FICO模块-财务账期的打开和关闭

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[FICO系列]SAP FICO模块-财务账期的 ...

  7. springMvc中自定义bean转换接收前台传的参数

    转载:https://blog.csdn.net/u013476435/article/details/81538099 因前端整体传参时,参数名都不是驼峰写法,类似 music_name,music ...

  8. jQuery遍历集合

     jQuery 遍历List集合 $(function(){ var tbody = ""; var obj =[{"name ":"xxxx&quo ...

  9. JavaScript.import

    // --file.js-- function getJSON(url, callback) {   let xhr = new XMLHttpRequest();   xhr.onload = fu ...

  10. Pandas matplotlib 无法显示中文

    Pandas 无法显示中文问题 解决方案 Pandas在绘图时,会显示中文为方块,主要原因有二:   matplotlib 字体问题seaborn 字体问题 (实际上,matplotlib是支持uni ...