class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x < 0:
return False
x=str(x)
i=0
j=len(x)-1
while i < j:
if x[i] != x[j]:
return False
i+=1
j-=1
return True

leetcode Palindrome Number python的更多相关文章

  1. leetcode:Palindrome Number【Python版】

    一次AC 题目要求中有空间限制,因此没有采用字符串由量变向中间逐个对比的方法,而是采用计算翻转之后的数字与x是否相等的方法: class Solution: # @return a boolean d ...

  2. [LeetCode] Palindrome Number 验证回文数字

    Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...

  3. [leetcode]Palindrome Partitioning @ Python

    原题地址:https://oj.leetcode.com/problems/palindrome-partitioning/ 题意: Given a string s, partition s suc ...

  4. [Leetcode]Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. 这题貌似解法挺多,直接用简单的把数倒置,没有考虑数 ...

  5. leetcode:Palindrome Number (判断数字是否回文串) 【面试算法题】

    题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could neg ...

  6. [leetcode]Valid Number @ Python

    原题地址:http://oj.leetcode.com/problems/valid-number/ 题意:判断输入的字符串是否是合法的数. 解题思路:这题只能用确定有穷状态自动机(DFA)来写会比较 ...

  7. LeetCode——Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...

  8. [Leetcode] Palindrome number 判断回文数

    Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...

  9. leetcode Single Number python

    #question : Given an array of integers, every element appears twice except for one. Find that single ...

随机推荐

  1. Proud Merchants(01背包)

    Proud Merchants Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) To ...

  2. PHP自学2——将用户提交表单存储到外部普通文件中

    在上一节中我们已经实现了将用户的订单信息提交到服务器端,然后服务器端将提交信息返回并显示到页面上.这一节将把上一节用户的订单信息保存到外部的普通文件中(即.txt文本文件中). 本节代码将用户提交的订 ...

  3. JavaWeb Filter--过滤器 简介

    本文转载自:http://blog.csdn.net/wanghuan203/article/details/7325651 过滤器就是在源数据和目的数据之间起过滤作用的中间件. Web应用中,在处理 ...

  4. FAQ:win7和win8 64位注册ocx控件方法

    win7/win8 问题所在: 64位的系统一般都是可以安装32位程序的, 执行         C:\Windows\SysWOW64\regsvr32.exe 而不是 C:\Windows\Sys ...

  5. 如何在MyEclipse中部署struts2的环境

    总记不住一些部署struts2框架的细节,下面就做一个总结:其实很简单,只要几步:1.下载的strutsXXX(版本号)-zip文件中解压app目录中有一个struts2-blank.war文件,解压 ...

  6. Mysql中时间的操作笔记

    1.创建修改表时,为datetime字段设置当前时间为默认值 CREATE TABLE `NewTable` ( `id` int(11) NOT NULL AUTO_INCREMENT , `des ...

  7. Properties读写资源文件

    Java中读写资源文件最重要的类是Properties,功能大致如下: 1. 读写Properties文件 2. 读写XML文件 3. 不仅可以读写上述两类文件,还可以读写其它格式文件如txt等,只要 ...

  8. WordPress下载安装简单配置实例

    1.下载https://cn.wordpress.org/ 2.复制wp-config-sample.php为wp-config.php 3.创建一个wordpress数据库 4.修改wp-confi ...

  9. C#access数据库操作

    比较凌乱,有时间在整理吧. Provider=Microsoft.Jet.OLEDB.!" private void GetCon() { string strConnection=&quo ...

  10. [问题解决] Could not update ICEauthority file /home/username/.ICEauthority

    错误: Could not update ICEauthority file /home/username/.ICEauthority 发生场景: 虚拟机下的ubuntu server12.04 解决 ...