当前位置:网站首页>[LeetCode] 回文数【9】
[LeetCode] 回文数【9】
2022-07-02 22:06:00 【山茶花开时。】
问题: 给你一个整数x,如果x是一个回文整数,返回True;否则,返回False
回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。例如,121是回文,而123不是
示例1
输入: x = 121
输出: True
示例2
输入: x = -121
输出: False
解释: 从左向右读,为-121,从右向左读,为121- ,因此它不是一个回文数
示例3
输入: x = 10
输出: False
解释: 从右向左读,为01,因此它不是一个回文数
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)边栏推荐
- C language, to achieve three chess games
- 图形视图框架
- 数据库系统概论第一章简答题-期末考得怎么样?
- NC24325 [USACO 2012 Mar S]Flowerpot
- U++ learning notes - relaxation
- Pointer array parameter passing, pointer parameter passing
- Market Research - current situation and future development trend of herringbone gear Market
- Build your own website (22)
- Oracle-PL/SQL编程
- 大话云原生之负载均衡篇-小饭馆客流量变大了
猜你喜欢

Oracle cursor

20220702 how do programmers build knowledge systems?

It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #

SimpleITK使用——4. 奇怪的问题

scrcpy这款软件解决了和同事分享手机屏幕的问题| 社区征文

phpcms实现订单直接支付宝支付功能

牛客网:龙与地下城游戏
![[shutter] shutter application life cycle (foreground state resumed | background state paused | inactive | component separation state detached)](/img/4c/c8dae41fc2eb18b5153cf36861fc7d.jpg)
[shutter] shutter application life cycle (foreground state resumed | background state paused | inactive | component separation state detached)

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

`${}`的用法
随机推荐
Using emqx cloud to realize one machine one secret verification of IOT devices
Introduction to database system Chapter 1 short answer questions - how was the final exam?
[shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
Market Research - current situation and future development trend of marine clutch Market
Unity3d learning notes 4 - create mesh advanced interface
ArrayList analysis 2: pits in ITR, listiterator, and sublist
PHP wechat red packet grabbing algorithm
Simpleitk use - 4 Strange question
wait解决僵尸进程
Utilisation de simpletk - 4. Question étrange
佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
Market Research - current market situation and future development trend of aircraft audio control panel system
Simpleitk use - 3 Common operations
PHP implements querying the data matching the date of birth according to the entered age
SimpleITK使用——3. 常见操作
Micro service gateway selection, please accept my knees!
"Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks!
Mathematical modeling -- graph and network models and methods (I)
UE4 游戏架构 学习笔记
Market Research - current situation and future development trend of anti-counterfeiting label market