题目描述:

自己的提交:

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. MySQL- 查询总结

    查询总结 语法: select 查询字段 from 表 别名 连接类型inner|left|right join on 连接条件 where 筛选 group by 分组列表 having 筛选(二次 ...

  2. 批量更新:A表数据源 B表目标

    update a set a.Title = b.Title from Table_A a ,Tbale_B b where a.ID_Table_B = b.ID

  3. [洛谷P3261] [JLOI2015]城池攻占(左偏树)

    不得不说,这道题目是真的难,真不愧它的“省选/NOI-”的紫色大火题!!! 花了我晚自习前半节课看题解,写代码,又花了我半节晚自习调代码,真的心态爆炸.基本上改得和题解完全一样了我才过了这道题!真的烦 ...

  4. hdu 4453 约会安排(线段树区间合并)

    约会安排 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  5. 【java】jstack分析查看线程状态

    演示代码 public class StackTest { public static void main(String[] args) { Thread thread = new Thread(ne ...

  6. Zookeeper——启动闪退

      Zookeeper好久不启动了,昨天项目要用Zookeeper了,我昨天突然启动它,调皮的zk居然害羞不让我看见它,启动不了,一启动就闪退,为啥呢?其实是因为报错了,有错zk启动时就会报错,所以昨 ...

  7. web.config增加组和调用

    一,在web.config中的configuration节点下我们可以添加自己的配置,如下: <TestSectionGroup> <TestSection> <add ...

  8. zabbix 微信告警脚本

    #!/usr/bin/env python3 import requests import json import sys import os def access_token(Corpid,Secr ...

  9. 20180305-Python中迭代器和生成器

    一.迭代器 迭代器是访问集合元素的一种方式.迭代器从访问到集合的第一个元素开始访问,直到所有元素被访问结束.而且迭代器只能往前访问,不能后退.另外迭代器的另一个优点,不会事先准备好访问的集合的所有元素 ...

  10. NVIDIA Jetson TK1 开发板

    TEGRA K1 — 全球的移动处理器 创新的全新 Tegra K1 处理器包含 NVIDIA Kepler™ 架构 GPU,与全球强超级计算机和 PC 游戏系统所采用的 GPU 无异.这种 GPU ...