当前位置:网站首页>The number of reversing twice in leetcode simple question
The number of reversing twice in leetcode simple question
2022-07-06 15:04:00 【·Starry Sea】
subject
reverse An integer means inverting all its bits .
for example , reverse 2021 obtain 1202 . reverse 12300 obtain 321 , Do not retain leading zeros .
Give you an integer num , reverse num obtain reversed1 , Then reverse reversed1 obtain reversed2 . If reversed2 be equal to num , return true ; otherwise , return false .
Example 1:
Input :num = 526
Output :true
explain : reverse num obtain 625 , Then reverse 625 obtain 526 , be equal to num .
Example 2:
Input :num = 1800
Output :false
explain : reverse num obtain 81 , Then reverse 81 obtain 18 , It's not equal to num .
Example 3:
Input :num = 0
Output :true
explain : reverse num obtain 0 , Then reverse 0 obtain 0 , be equal to num .
Tips :
0 <= num <= 10^6
source : Power button (LeetCode)
Their thinking
As long as a bit is 0 And not a single digit , Then the reversal will not succeed , Otherwise, success .
class Solution:
def isSameAfterReversals(self, num: int) -> bool:
return False if str(num)[-1]=='0' and len(str(num))>1 else True

边栏推荐
- 【指针】查找最大的字符串
- [oiclass] share prizes
- [pointer] octal to decimal
- Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
- If the position is absolute, touchablehighlight cannot be clicked - touchablehighlight not clickable if position absolute
- 王爽汇编语言学习详细笔记一:基础知识
- Interview Essentials: what is the mysterious framework asking?
- 【指针】求解最后留下的人
- [issue 18] share a Netease go experience
- Query method of database multi table link
猜你喜欢

ucore lab8 文件系统 实验报告

Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)

ucore lab2 物理内存管理 实验报告

“Hello IC World”

CSAPP家庭作业答案7 8 9章

Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator

"If life is just like the first sight" -- risc-v

Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class

四元数---基本概念(转载)

ucore lab1 系统软件启动过程 实验报告
随机推荐
Global and Chinese market of portable and handheld TVs 2022-2028: Research Report on technology, participants, trends, market size and share
【指针】求二维数组中最大元素的值
指針:最大值、最小值和平均值
5 minutes to master machine learning iris logical regression classification
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
With 27K successful entry ByteDance, this "software testing interview notes" has benefited me for life
[HCIA continuous update] advanced features of routing
“人生若只如初见”——RISC-V
Fundamentals of digital circuit (V) arithmetic operation circuit
Report on the double computer experiment of scoring system based on 485 bus
STC-B学习板蜂鸣器播放音乐
Keil5-MDK的格式化代码工具及添加快捷方式
Opencv recognition of face in image
Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)
About the garbled code problem of superstar script
[pointer] octal to decimal
“Hello IC World”
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
Query method of database multi table link
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code