当前位置:网站首页>[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)边栏推荐
- Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
- [LeetCode] 反转字符串【344】
- Hanging mirror security won four global infosec awards on rsac2022
- The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
- UE4 UI自适应屏幕
- 【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
- 佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
- Film and television excerpts
- Golang面试整理 三 简历如何书写
- php优化foreach中的sql查询
猜你喜欢

附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)

Dahua cloud native load balancing article - the passenger flow of small restaurants has increased

Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?

【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线

Commodity information management system (C language document version)

Oracle PL / SQL programming

Source code analysis - lightweight asynchronous crawler framework Ruia
![[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)](/img/2b/f31b81cedf37ca187bcaa20dfe0b83.png)
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)

NC50965 Largest Rectangle in a Histogram

Utilisation de simpletk - 4. Question étrange
随机推荐
Socket套接字C/S端流程
Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
世界环境日 | 周大福用心服务推动减碳环保
【板栗糖GIS】arcscene—如何做出有高度的高程图
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
[LeetCode] 多数元素【169】
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?
[autosar-dcm] - 4.3-how UDS $22 and $2e services read and write NVM data
杰理之、产线装配环节【篇】
UE4 game architecture learning notes
go 条件变量
Film and television excerpts
位的高阶运算
go 多线程数据搜索
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
Radis:Linux上安装Redis(步骤)
【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
[LeetCode] 存在重复元素【217】
全面解析分享购商业模式逻辑?分享购是如何赋能企业
UE4 游戏架构 学习笔记