[LeetCode] Rotated Digits 旋转数字
X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotated - we cannot choose to leave it alone.
A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rotate to each other; 6 and 9 rotate to each other, and the rest of the numbers do not rotate to any other number and become invalid.
Now given a positive number N, how many numbers X from 1 to N are good?
Example:
Input: 10
Output: 4
Explanation:
There are four good numbers in the range [1, 10] : 2, 5, 6, 9.
Note that 1 and 10 are not good numbers, since they remain unchanged after rotating.
Note:
- N will be in range
[1, 10000].
这道题定义了一种好数字,就是把每位上的数字自身翻转一下,能得到一个不同的数字。翻转规则定义为,0,1,和8翻转后还为其本身,2和5,6和9可以互相翻转。然后给了一个数字N,问 [1, N] 区间内共有多少个这样的好数字。这道题大家踩
[LeetCode] Rotated Digits 旋转数字的更多相关文章
- LeetCode 788. Rotated Digits (旋转数字)
X is a good number if after rotating each digit individually by 180 degrees, we get a valid number t ...
- Leetcode788.Rotated Digits旋转数字
我们称一个数 X 为好数, 如果它的每位数字逐个地被旋转 180 度后,我们仍可以得到一个有效的,且和 X 不同的数.要求每位数字都要被旋转. 如果一个数的每位数字被旋转以后仍然还是一个数字, 则这个 ...
- 788. Rotated Digits 旋转数字
[抄题]: X is a good number if after rotating each digit individually by 180 degrees, we get a valid nu ...
- [LeetCode] Add Digits 加数字
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...
- leetCode题解之旋转数字
1.题目描述 X is a good number if after rotating each digit individually by 180 degrees, we get a valid n ...
- Leetcode: Rotated Digits
X is a good number if after rotating each digit individually by 180 degrees, we get a valid number t ...
- LeetCode 788. 旋转数字(Rotated Digits) 36
788. 旋转数字 788. Rotated Digits 题目描述 我们称一个数 X 为好数, 如果它的每位数字逐个地被旋转 180 度后,我们仍可以得到一个有效的,且和 X 不同的数.要求每位数字 ...
- Java实现 LeetCode 788 旋转数字(暴力)
788. 旋转数字 我们称一个数 X 为好数, 如果它的每位数字逐个地被旋转 180 度后,我们仍可以得到一个有效的,且和 X 不同的数.要求每位数字都要被旋转. 如果一个数的每位数字被旋转以后仍然还 ...
- LeetCode 81——搜索旋转排序数组 II
1. 题目 2. 解答 2.1. 方法一 基于 LeetCode 33--搜索旋转排序数组 中的方法二. 当 nums[mid] = nums[right] 时,比如 [1, 1, 2, 1, 1], ...
随机推荐
- China-global view
Good morning everyone. Everyone here would know this year Xia’Men held the BRICS business forum.In a ...
- LINUX 常用命令(一)
1.LINUX系统常用命令实例: A0 LINUX命令分内置命令和非内置命令! 一般而言,内置命令就是指在/bin ./usr/bin下系统默认的命令! 非内置命令需要加上命令的绝对路径执行!比如我们 ...
- 定期清理WordPress的文章修订版本
当WordPress编辑或修改文章时会自动保存生成一个修订版本,默认是每分钟1次.方便恢复早先撰写的版本.不过时间一长就会产生大量的冗余数据,加重服务器负担,拖慢数据加载.当所有发布的文章都已更新到最 ...
- vue使用md5,base64方法
在前端加密代码虽然对安全没有提高,但是可以避免明文传输,提供用户隐私保护,还是很有必要的. 首先安装js-md5,js-base64. 在vue中引入. 之后就可以直接使用了,一般的做法是先把密码转行 ...
- Webform——JQuery基础(选择器、事件、DOM操作)
一.选择器 1.基本选择器 ①id选择器:# ②class选择器:. ③标签名选择:标签名 ④并列选择:用,隔开 ⑤后代选择:用空格隔开 代码用法展示: ...
- vmware 14 密钥
VMware 2017 v14.x 永久许可证激活密钥 FF31K-AHZD1-H8ETZ-8WWEZ-WUUVA CV7T2-6WY5Q-48EWP-ZXY7X-QGUWD 来源链接: http:/ ...
- Django之Xadmin
零.预备知识 单例对象 方式一:__new__方法 方式二:模块导入,只要在引入的文件中实例了这个对象,不管引道哪里,这个对象都指向同一个内存空间 class My_singleton(object) ...
- NB-IoT不一定最完美 但足以成为决定ofo与摩拜物联网胜负的关键【转】
转自:http://news.rfidworld.com.cn/2017_11/3d5ed5c5d8cb9949.html 2018年到来之前,如果还不懂物联网,你会被淘汰. 今年1月,工信部< ...
- ActiveMQ简单介绍及安装
消息中间件 我们简单的介绍一下消息中间件,对它有一个基本认识就好,消息中间件(MOM:Message Orient middleware). 消息中间件有很多的用途和优点: 1. 将数据从一个应用程序 ...
- prototype、proto、constructor 之间的关系