当前位置:网站首页>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

边栏推荐
- Global and Chinese market of RF shielding room 2022-2028: Research Report on technology, participants, trends, market size and share
- "If life is just like the first sight" -- risc-v
- Function: string storage in reverse order
- Global and Chinese market of DVD recorders 2022-2028: Research Report on technology, participants, trends, market size and share
- Es full text index
- The common methods of servlet context, session and request objects and the scope of storing data in servlet.
- Common Oracle commands
- Opencv recognition of face in image
- Oracle foundation and system table
- Summary of thread implementation
猜你喜欢

Express

Logstack introduction and deployment -- elasticstack (elk) work notes 019

High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters

Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code

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

CSAPP homework answers chapter 789

Opencv recognition of face in image

"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

Fundamentals of digital circuits (III) encoder and decoder
随机推荐
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
CSAPP homework answers chapter 789
Face and eye recognition based on OpenCV's own model
What is an index in MySQL? What kinds of indexes are commonly used? Under what circumstances will the index fail?
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
C language do while loop classic Level 2 questions
王爽汇编语言详细学习笔记二:寄存器
Stc-b learning board buzzer plays music
“Hello IC World”
Function: find the root of the equation by Newton iterative method
Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)
[HCIA continuous update] working principle of static route and default route
【指针】删除字符串s中的所有空格
后台登录系统,JDBC连接数据库,做小案例练习
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
Wang Shuang's detailed learning notes of assembly language II: registers
With 27K successful entry ByteDance, this "software testing interview notes" has benefited me for life
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set