1、题目
9. Palindrome Number
 

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

Example 1:

Input: 121
Output: true

Example 2:

Input: -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.

Example 3:

Input: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

Follow up:

Coud you solve it without converting the integer to a string?


2、我的解法
 # -*- coding: utf-8 -*-
# @Time : 2020/1/27 17:28
# @Author : SmartCat0929
# @Email : 1027699719@qq.com
# @Link : https://github.com/SmartCat0929
# @Site :
# @File : 9. Palindrome Number.py class Solution:
def isPalindrome(self, x: int) -> bool:
if x > 0:
r = 0
y = str(x)
n = len(y)
d = []
for i in (y):
d.append(i)
for j in range(n):
c = d.pop()
r = r + c
v = int(r)
if v == x:
return v
else:
return 0
elif x== 0:
return True
else:
return 0 print(Solution().isPalindrome(12321))


  

leetCode练题——9. Palindrome Number的更多相关文章

  1. LeetCode算法题-Reach a Number(Java实现)

    这是悦乐书的第310次更新,第331篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第179题(顺位题号是754).你站在无限数字线的0号位置.在目的地有个target.在 ...

  2. LeetCode算法题-Valid Palindrome II(Java实现)

    这是悦乐书的第287次更新,第304篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第155题(顺位题号是680).给定非空字符串s,最多可以删除一个字符. 判断它是否是回 ...

  3. LeetCode算法题-Third Maximum Number(Java实现-四种解法)

    这是悦乐书的第222次更新,第235篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第89题(顺位题号是414).给定非空的整数数组,返回此数组中的第三个最大数字.如果不存 ...

  4. LeetCode算法题-Longest Palindrome(五种解法)

    这是悦乐书的第220次更新,第232篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第87题(顺位题号是409).给定一个由小写或大写字母组成的字符串,找到可以用这些字母构 ...

  5. LeetCode算法题-Convert a Number to Hexadecimal(Java实现)

    这是悦乐书的第219次更新,第231篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第86题(顺位题号是405).给定一个整数,写一个算法将其转换为十六进制.对于负整数,使 ...

  6. LeetCode算法题-Valid Palindrome(Java实现)

    这是悦乐书的第174次更新,第176篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第33题(顺位题号是125).给定一个字符串,确定它是否是回文,只考虑字母数字字符并忽略 ...

  7. Leetcode 题目整理-3 Palindrome Number & Roman to Integer

    9. Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. clic ...

  8. LeetCode专题-Python实现之第9题:Palindrome Number

    导航页-LeetCode专题-Python实现 相关代码已经上传到github:https://github.com/exploitht/leetcode-python 文中代码为了不动官网提供的初始 ...

  9. 【LeetCode每天一题】Palindrome Number( 回文数字)

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...

随机推荐

  1. 如何在windows和linux搭建django环境

    注:本文以python3为例,python2.x是一样的不再赘述 提前准备: python/python3已经安装好,如果没有请参考以下资料进行安装 linux安装python3 win安装pytho ...

  2. java.sql.SQLException: Access denied for user 'gaoqi'@'127.0.0.1' (using password: YES)

    GRANT ALL PRIVILEGES ON *.* TO root @'%' IDENTIFIED BY "mypassword";--%表示所有的IP都能访问,也可以修改为专 ...

  3. bugku 输入密码查看flag

    首先进入网页会看到一个网页 然后用bp进行爆破 首先点击clear 然后选中刚下随便输入进去的密码点击add然后设置一下类型 然后进行开始攻击 攻击过程中点击length 根据长度可以判断出密码然后回 ...

  4. AcWing 850. Dijkstra求最短路 II 堆优化版 优先队列 稀疏图

    //稀疏图 点和边差不多 #include <cstring> #include <iostream> #include <algorithm> #include ...

  5. [linux] 手机Deploy linux 桌面中文乱码

    在手机上安装Deploy之后 通过VNC连接桌面,中文出现乱码 是方块乱码 这个是字体缺失造成的 安装字体就好了 我安装的是kali 桌面是LXDE sudo apt-get install font ...

  6. Java - JVM - jinfo

    1. 概述 jinfo java 运行时的配置工具 查看 设置 2. 环境 idea 2018.2 java jdk8 3. 准备 写个 死循环 概述 需要查看 jvm 的信息, 必须有个运行中的 j ...

  7. PHP通过thrift2访问HBASE

    前一段时间需要在网页上显示HBASE查询的结果,考虑用PHP来实现,在网上搜了一下,普遍都是用thrift作为接口来实现的.​ 参考博文:​ http://www.cnblogs.com/scotom ...

  8. Linux中Oracle启动侦听报错TNS:permission denied的解决方法

    最近在开发环境 oracle 启动侦听的时候,出现了 TNS:permission denied 的问题,通过网上和咨询朋友,最终找到了解决方案,现在共享出来给有需要的朋友. [oracle@orac ...

  9. Go语言fmt.Printf使用指南

    文章引用自 fmt fmt包实现了类似C语言printf和scanf的格式化I/O.主要分为向外输出内容和获取输入内容两大部分. 向外输出 标准库fmt提供了以下几种输出相关函数. Print Pri ...

  10. sockfd_to_family函数

    #include <sys/socket.h> #include <netinet/in.h> #define SA struct sockaddr int sockfd_to ...