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. KMP模式匹配 三(弦)

    原文请訪问我的博客:xiaoshig.sinaapp.com KMP模式匹配 三(串) Time Limit:1000MS     Memory Limit:131072KB     64bit IO ...

  2. JS原型,Prototype,原型

    对于javascript这样一种前端语言,个人觉得,要真正的理解其oop, 就必须要彻底搞清楚javascript的对象,原型链,作用域,闭包,以及this所引用的对象等概念.这些对弄明白了,应该就可 ...

  3. Excel中公式的绝对引用和相对引用单元格

    在Excel的表格中,非常常用的就是公式里的绝对引用和相对引用了,具体情况请看下列表格吧. 步骤1 打开做好的excel表格.公式中的相对单元格引用是基于包含公式和单元格引用的单元格的相对位置,若公式 ...

  4. c++中,保证头文件只被编译一次,避免多重包含的方法

    保证头文件只被编译一次 #pragma once这是一个比较常用的C/C++杂注,只要在头文件的最开始加入这条杂注,就能够保证头文件只被编译一次. #pragma once是编译器相关的,有的编译器支 ...

  5. ORA-32001: 已请求写入 SPFILE, 但是在启动时未指定 SPFILE

    SQL> alter system set smtp_out_server='smtp.126.com' scope=both;alter system set smtp_out_server= ...

  6. 20151225--easyUI

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  7. js——DOM操作(一)

    DOM:Document Object Model  文档对象模型 文档:html页面 文档对象:页面中元素 文档对象模型:定义  为了能够让程序(js)去操作页面中的元素 DOM会把文档看作是一棵树 ...

  8. 内存管理之二——Cocos2d-x学习历程(六)

    1.工厂方法 工厂方法是程序设计中一个经典的设计模式,指的是基类中只定义创建对象的接口,将实际的实现推迟到子类中. CCObject* factoryMethod() { CCObject* ret ...

  9. leetcode Sudoku Solver python

    #the define of Sudoku is on this link : http://sudoku.com.au/TheRules.aspx Write a program to solve ...

  10. ecshop开发日志之手机端虚拟商品自动发货

    在ecshop官方模版收,web端的虚拟商品购买后不能像pc端那般直接在付款后出现虚拟商品的卡号,密码,截止日期一下为让手机购买也可以在付款后自动显示发货并能显示卡号密码截止日期首 先找到pc端的fl ...