当前位置:网站首页>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
边栏推荐
- 函数:用牛顿迭代法求方程的根
- To brush the video, it's better to see if you have mastered these interview questions. Slowly accumulating a monthly income of more than 10000 is not a dream.
- 函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
- JDBC 的四种连接方式 直接上代码
- Fundamentals of digital circuits (III) encoder and decoder
- [pointer] find the value of the largest element in the two-dimensional array
- The common methods of servlet context, session and request objects and the scope of storing data in servlet.
- Description of Vos storage space, bandwidth occupation and PPS requirements
- Install and run tensorflow object detection API video object recognition system of Google open source
- 5分钟掌握机器学习鸢尾花逻辑回归分类
猜你喜欢
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
数字电路基础(三)编码器和译码器
Fundamentals of digital circuits (III) encoder and decoder
CSAPP homework answers chapter 789
Database monitoring SQL execution
STC-B学习板蜂鸣器播放音乐2.0
Fundamentals of digital circuit (V) arithmetic operation circuit
STC-B学习板蜂鸣器播放音乐
Soft exam information system project manager_ Project set project portfolio management --- Senior Information System Project Manager of soft exam 025
随机推荐
数字电路基础(四) 数据分配器、数据选择器和数值比较器
Why can swing implement a form program by inheriting the JFrame class?
Login the system in the background, connect the database with JDBC, and do small case exercises
【指针】求二维数组中最大元素的值
DVWA exercise 05 file upload file upload
Summary of thread implementation
Fundamentals of digital circuits (II) logic algebra
Wang Shuang's detailed learning notes of assembly language II: registers
后台登录系统,JDBC连接数据库,做小案例练习
What level do 18K test engineers want? Take a look at the interview experience of a 26 year old test engineer
Global and Chinese markets for complex programmable logic devices 2022-2028: Research Report on technology, participants, trends, market size and share
Investment operation steps
[pointer] solve the last person left
指针--剔除字符串中的所有数字
Logstack introduction and deployment -- elasticstack (elk) work notes 019
指针 --按字符串相反次序输出其中的所有字符
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
Flash implements forced login
CSAPP家庭作業答案7 8 9章
【指针】数组逆序重新存放后并输出