当前位置:网站首页>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 pinhole glossmeter 2022-2028: Research Report on technology, participants, trends, market size and share
- DVWA exercise 05 file upload file upload
- Global and Chinese market of portable and handheld TVs 2022-2028: Research Report on technology, participants, trends, market size and share
- 使用 flask_whooshalchemyplus jieba实现flask的全局搜索
- Matplotlib绘图快速入门
- What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
- 【指针】查找最大的字符串
- “Hello IC World”
- Common Oracle commands
- HackTheBox-Emdee five for life
猜你喜欢

Software testing interview summary - common interview questions

MySQL development - advanced query - take a good look at how it suits you

Summary of thread implementation

About the garbled code problem of superstar script

数字电路基础(三)编码器和译码器

The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?

How to transform functional testing into automated testing?

CSAPP家庭作业答案7 8 9章

“Hello IC World”

“人生若只如初见”——RISC-V
随机推荐
CSAPP homework answers chapter 789
Fundamentals of digital circuit (V) arithmetic operation circuit
ByteDance ten years of experience, old bird, took more than half a year to sort out the software test interview questions
{1,2,3,2,5} duplicate checking problem
Function: string storage in reverse order
ES全文索引
[Ogg III] daily operation and maintenance: clean up archive logs, register Ogg process services, and regularly back up databases
Database monitoring SQL execution
Build your own application based on Google's open source tensorflow object detection API video object recognition system (I)
Four methods of exchanging the values of a and B
China's county life record: go upstairs to the Internet, go downstairs' code the Great Wall '
Common Oracle commands
Global and Chinese market for antiviral coatings 2022-2028: Research Report on technology, participants, trends, market size and share
数据库多表链接的查询方式
数字电路基础(一)数制与码制
“人生若只如初见”——RISC-V
CSAPP家庭作业答案7 8 9章
【指针】统计一字符串在另一个字符串中出现的次数
数字电路基础(四) 数据分配器、数据选择器和数值比较器
What is an index in MySQL? What kinds of indexes are commonly used? Under what circumstances will the index fail?