[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], ...
随机推荐
- [再寄小读者之数学篇](2014-05-23 $\ln x-ax=0$ 有两个根时的估计)
已知函数 $f(x)=\ln x-ax$, 其中 $a$ 为常数. 如果 $f(x)$ 有两个零点 $x_1,x_2$. 试证: $x_1x_2>e^2$. 证明: 由 $$\bex \ln x ...
- 使用select为描述符设置超时
int readable_timeo(int fd, int sec) { fd_set rset; struct timeval tv; FD_ZERO(&rset); FD_SET(fd, ...
- ORACLE使用CASE WHEN的方法
先写草稿. 说下我的需求,ORACLE数据库有两个字段RECEIVER_MOBILE与RECEIVER_PHONE,同为联系方式.当RECEIVER_MOBILE为空的时候,需要用到RECEIVER_ ...
- 【汇总目录】Python
跟廖雪峰老师学Python笔记 [2019年03月29日] 匿名函数 [2019年03月25日] 返回函数与闭包 [2019年03月25日] sorted [2019年03月25日] filter [ ...
- CEYE平台的使用
0x01 CEYE 是什么 CEYE是一个用来检测带外(Out-of-Band)流量的监控平台,如DNS查询和HTTP请求.它可以帮助安全研究人员在测试漏洞时收集信息(例如SSRF / XXE / R ...
- python开发遇到的坑(2)mongodb安装路径权限问题
个人比较懒,Mac 电脑直接使用命令行安装,brew install mongodb,但是遇到两个问题,其一: Error: The following directories are not wri ...
- 简单SQL注入
既然是简单的,估计也就是''字符型把,输入'or'1 以下是输出结果,or没被过滤,单引号也没有 呢么用union联合注入试试,提交了'-1 union/**/select 1 and '1,发现回显 ...
- MySQL平滑删除数据的小技巧【转】
今天接到一位开发同学的数据操作需求,需求看似很简单,需要执行下面的SQL语句: delete from test_track_log where log_time < '2019-1-7 00: ...
- ospf的虚连接配置
作者:邓聪聪 配置OSPF虚连接 组网需求 在图1中,Area2没有与骨干区域直接相连.Area1被用作传输区域(Transit Area)来连接Area2和Area0.SwitchA.SwitchB ...
- 通过fiddler和逍遥模拟器模拟抓包android手机
环境说明 Fiddler/逍遥手机模拟器 安装在10.11.0.148的电脑中 逍遥模拟器会自动生成wifi连接到 10.11.0.148上网 开启https: 在模拟器中打开 http://代理:8 ...