当前位置:网站首页>[leetcode] number of palindromes [9]
[leetcode] number of palindromes [9]
2022-07-02 22:52:00 【When camellia flowers bloom.】
problem : Give you an integer x, If x Is a palindrome integer , return True; otherwise , return False
Palindrome number It refers to positive order ( From left to right ) Reverse order ( From right to left ) Read all the same integers . for example ,121 It's palindrome. , and 123 No
Example 1
Input : x = 121
Output : True
Example 2
Input : x = -121
Output : False
explain : Read left to right , by -121, Read right to left , by 121- , So it's not a palindrome number
Example 3
Input : x = 10
Output : False
explain : Read right to left , by 01, So it's not a palindrome number
def isPalindrome(x):
str_x = str(x)
reverse_str_x = str_x[::-1]
if reverse_str_x == str_x:
return True
else:
return False
isPalindrome(121)
isPalindrome(10)
isPalindrome(-121)
边栏推荐
- [LeetCode] 数组中的第K个最大元素【215】
- NC24325 [USACO 2012 Mar S]Flowerpot
- 任务和特权级保护
- Hanging mirror security won four global infosec awards on rsac2022
- Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
- 杰理之如何测试按键的误触率【篇】
- JS solution for obtaining the width and height of hidden elements whose display is none
- [LeetCode] 回文数【9】
- Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
- 原生js添加样式的方法
猜你喜欢
Oracle cursor
SimpleITK使用——4. 奇怪的问题
Oracle-游标
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Simpleitk use - 3 Common operations
Phpcms realizes the direct Alipay payment function of orders
手写ORM(对象关系映射)增删改查
PMP项目整合管理
Performance optimization - rigorous mode
Addition, deletion, modification and query of handwritten ORM (object relationship mapping)
随机推荐
Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
PMP项目整合管理
送给即将工作的自己
#include errors detected. Please update your includePath.
Phpcms realizes the direct Alipay payment function of orders
Socket套接字C/S端流程
杰理之修改不需要长按开机功能【篇】
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
解决 excel 文件上传时更改选中的文件出现错误net::ERR_UPLOAD_FILE_CHANGED
Go four singleton modes
全面解析分享购商业模式逻辑?分享购是如何赋能企业
Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
牛客网:龙与地下城游戏
Jerry's modification does not require long press the boot function [chapter]
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
go 条件变量
go 4种单例模式
Commodity information management system (C language document version)
杰理之、产线装配环节【篇】
杰理之内置短按再长按,不管长按多长时间都是短按【篇】