1、题目描述

2、代码

 int rotatedDigits(int N) {
int res = ; for (int i = ; i <= N; i++) {
if (isGood(i)) {
res++;
}
} return res;
} bool isGood(int x)
{
int rx = x;
vector<int> nums;
while (x) {
int r = x % ;
nums.push_back(r);
x = x / ;
} for (vector<int>::iterator it = nums.begin(); it != nums.end(); it++ ) {
if (*it == || *it == || *it == )
return false;
if (*it == || *it == || *it == )
continue; if (*it == ) {
*it = ;
continue;
} if (*it == ) {
*it = ;
continue;
} if (*it == ) {
*it = ;
continue;
} if (*it == ) {
*it = ;
continue;
}
} int good = ;
for (vector<int>::reverse_iterator ite = nums.rbegin(); ite != nums.rend(); ite++) {
good = good * + *ite;
} return good != rx;
}

LeetCode题解之Rotated Digits的更多相关文章

  1. LeetCode算法题-Rotated Digits(Java实现)

    这是悦乐书的第316次更新,第337篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第185题(顺位题号是788).如果一个数字经过180度旋转后,变成了一个与原数字不同的 ...

  2. 【LeetCode】788. Rotated Digits 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  3. LeetCode 题解之Add Digits

    1.问题描述 2.问题分析 循环拆分数字,然求和判断. 3.代码 int addDigits(int num) { ) return num; int result = num; do{ vector ...

  4. 73th LeetCode Weekly Contest Rotated Digits

    X is a good number if after rotating each digit individually by 180 degrees, we get a valid number t ...

  5. [LeetCode 题解] Search in Rotated Sorted Array

    前言 [LeetCode 题解]系列传送门: http://www.cnblogs.com/double-win/category/573499.html 题目描述 Suppose an array ...

  6. LeetCode 788. 旋转数字(Rotated Digits) 36

    788. 旋转数字 788. Rotated Digits 题目描述 我们称一个数 X 为好数, 如果它的每位数字逐个地被旋转 180 度后,我们仍可以得到一个有效的,且和 X 不同的数.要求每位数字 ...

  7. [LeetCode 题解]:Palindrome Number

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Determine ...

  8. [LeetCode 题解]:Intersection of Two Linked Lists

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Suppose an ...

  9. [LeetCode 题解]: plusOne

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Given a no ...

随机推荐

  1. Android返回系统Home桌面

    Intent intent = new Intent(); // 为Intent设置Action.Category属性 intent.setAction(Intent.ACTION_MAIN);// ...

  2. linux和docker的capabilities介绍

    验证环境:centos7 x86/64 内核版本4.19.9 在linux 2.2版本之前,当内核对进程进行权限验证的时候,可以将进程划分为两类:privileged(UID=0)和unprivile ...

  3. mysql delimiter的说明

    默认情况下,mysql解释器一遇到分号(;),它就要自动执行. 不会等到用户把这些语句全部输入完之后,再执行整段语句. 而自定义函数和存储过程的SQL语句有好多行,且语句中包含有分号,为了保证整段语句 ...

  4. Async异步编程入门示例

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. 【杂谈】Java I/O的底层实现

    前言 Java I/O功能封装的很好,使用起来很方便,就是刚开始学的时候,如果不了解装饰器模式,会被他繁多的类给吓到.用多了也就习惯了,而且现在有很多实用的封装良好的实用类,可直接读写整个文件.开发者 ...

  6. java 写法推荐

    1. for循环 for (int i = 0; i < list.size(); i++) { int item = list.get(i); System.out.println(" ...

  7. Netty 高性能之道 - Recycler 对象池的复用

    前言 我们知道,Java 创建一个实例的消耗是不小的,如果没有使用栈上分配和 TLAB,那么就需要使用 CAS 在堆中创建对象.所以现在很多框架都使用对象池.Netty 也不例外,通过重用对象,能够避 ...

  8. [转]单据套打WINFORM实现,带预览功能

    本文转自:https://blog.csdn.net/lyflcear/article/details/22795053 昨天公司要打单子而不是以前的手写 为了实现这样的功能上网搜索了一下 http: ...

  9. XML Parsing Error: no element found Location: moz-nullprincipal:{23686e7a-652b-4348-92f4-7fb3575179ed} Line Number 1, Column 1:^

    “Hi Insus.NET, 我有参考你下午发布的一篇<jQuery.Ajax()执行WCF Service的方法>http://www.cnblogs.com/insus/p/37278 ...

  10. git命令学习总结

    学习git 主要是因为github官网共享的资源很有学习价值.最近转型JAVA,所有特意去学习了下git软件.git软件可以去官网下载最新版本. 进入 git 仓库目录 右击 选中 Git Bash ...