题目

class Solution {
public:
int ans[10005];
vector<int> sequentialDigits(int low, int high) { int x = 1;
int pos=0;
int tag=1;
for(int i=1;i<=9;i++)
{
x=fun2(x);
tag*=10;
int xx=x;
for(int j=1;j<=9-i;j++)
{
ans[pos++]=xx; xx=fun(xx,tag);
} } vector<int> res;
int tag2=0;
for(int i=0;i<pos;i++)
{
if(ans[i]>=low&&ans[i]<=high)
{
res.push_back(ans[i]);
} }
return res; } int fun(int x,int num)
{
int y =x%10; x%=num; x*=10;
x+=y+1;
return x;
} int fun2(int x)
{
int y = x%10;
x*=10;
x+=y+1; return x;
}
};

LeetCode 1291. Sequential Digits的更多相关文章

  1. 【leetcode】1291. Sequential Digits

    题目如下: An integer has sequential digits if and only if each digit in the number is one more than the ...

  2. [LeetCode] Reconstruct Original Digits from English 从英文中重建数字

    Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...

  3. [LeetCode] Remove K Digits 去掉K位数字

    Given a non-negative integer num represented as a string, remove k digits from the number so that th ...

  4. [LeetCode] Monotone Increasing Digits 单调递增数字

    Given a non-negative integer N, find the largest number that is less than or equal to N with monoton ...

  5. LeetCode:Add Digits - 非负整数各位相加

    1.题目名称 Add Digits (非负整数各位相加) 2.题目地址 https://leetcode.com/problems/add-digits/ 3.题目内容 英文:Given a non- ...

  6. LeetCode 258 Add Digits(数字相加,数字根)

    翻译 给定一个非负整型数字,反复相加其全部的数字直到最后的结果仅仅有一位数. 比如: 给定sum = 38,这个过程就像是:3 + 8 = 11.1 + 1 = 2.由于2仅仅有一位数.所以返回它. ...

  7. [LeetCode] 258. Add Digits 加数字

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  8. LeetCode 258. Add Digits

    Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only o ...

  9. 【LeetCode】Add Digits

    Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only ...

随机推荐

  1. commonDispatchException 函数的逆向

    看书中给出的内容: 1:在栈中构建 EXCEPTION_RECORD 结构体 2. 根据函数传递参数逆推得到 "判断先前模式"的反汇编代码

  2. Web前端——css

    css 推荐的样式编写顺序: Positioning:定位 Box model:盒子模型.大小等 Typographic:文字系列.排印等 Visual:可视化.背景等 Misc:其它混杂模式 居中 ...

  3. fastjson对于yyyy-MM-dd HH:mm格式的反序列化问题

    原创GrayHJX 发布于2017-03-14 22:56:33 阅读数 6851  收藏 展开 问题:最近在工作中遇到这么一个问题:有个实体类,它有个date类型的属性,当在这个属性加上fastjs ...

  4. python if语法

    1.查看数据类型 print(type(1)) 2.同类型:数字相加 ,字符串拼接 a=input("输:") print(int(a)+5) 3.单if条件语句 if if 3& ...

  5. Linux下迅速删除一个大文件夹

    rsync -av --delete /tmp/null/ ./        迅速删除大文件夹,如缓存 快速删除大目录(即大量文件)1.先建立一个空目录 mkdir /data/blank 2.用r ...

  6. appium----Monkey测试

    做过app测试的应该都知道Monkey测试,今天简单的介绍下Monkey如何测试 什么是Monkey monkey测试的原理就是利用socket通讯的方式来模拟用户的按键输入,触摸屏输入,手势输入等, ...

  7. Appium 定位

    使用过 Appium 的都知道,元素的定位方式有很多种,具体使用哪一种,主要看业务的需要和自己的使用爱好.下面总结一下,Appium 到底有哪些定位方式,定位的元素以下面截图指定的元素为例子:   这 ...

  8. 《anchor-based v.s. anchor-free》

    作者:青青子衿链接:https://www.zhihu.com/question/356551927/answer/926659692来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  9. 剑指Offer-3.从尾到头打印链表(C++/Java)

    题目: 输入一个链表,按链表从尾到头的顺序返回一个ArrayList. 分析: 很简单的一道题,其实也就是从尾到头打印链表,题目要求返回ArrayList,其实也就是一个数组. 可以将链表中的元素全部 ...

  10. JPA简介

    JPA的学习 JPA是Java Persistence API的简称,中文名Java持久层API.是Java EE5.0平台中Sun为了统一持久层ORM框架而制定的一套标准,注意是一套标准,而不是具体 ...