1、注意空字符串的处理;

2、注意是alphanumeric字符;

3、字符串添加字符直接用+就可以;

 class Solution:
# @param s, a string
# @return a boolean
def isPalindrome(self, s):
ret = False
s = s.lower()
ss = ""
for i in s:
if i.isalnum():
ss += i
h = 0
e = len(ss)-1
while(h<e):
if(ss[h] == ss[e]):
h += 1
e -= 1
else:
break
if h>=e:
ret = True
return ret

leetcode:Valid Palindrome【Python版】的更多相关文章

  1. [leetcode]Valid Palindrome @ Python

    原题地址:https://oj.leetcode.com/problems/valid-palindrome/ 题意: Given a string, determine if it is a pal ...

  2. leetcode Valid Palindrome C++&amp;python 题解

    题目描写叙述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...

  3. [LeetCode] Valid Palindrome 验证回文字符串

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  4. LeetCode——Valid Palindrome

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  5. [LeetCode] Valid Palindrome II 验证回文字符串之二

    Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...

  6. LeetCode Valid Palindrome II

    原题链接在这里:https://leetcode.com/problems/valid-palindrome-ii/description/ 题目: Given a non-empty string  ...

  7. Leetcode Valid Palindrome

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  8. LeetCode: Valid Palindrome [125]

    [题目] Given a string, determine if it is a palindrome, considering only alphanumeric characters and i ...

  9. LeetCode: Valid Palindrome 解题报告

    Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...

  10. [Leetcode] valid palindrome 验证回文

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

随机推荐

  1. 20170728xlVba SSC_LastTwoDays

    Public Sub SSCLastTwoDays() Dim strText As String Dim Reg As Object, Mh As Object, OneMh As Object D ...

  2. Sergey's problem CodeForces - 1019C (图论,构造,神题)

    链接 大意: 给定有向图, 求选择一个点集$S$, 使得$S$任意两点不相连, 且对于不属于$S$的任意点$x$, 均存在$S$中的点$y$, 使得$d(x,y)<=2$, $d(x,y)$为从 ...

  3. thinkphp得到客户端的ip

    /** * 获取客户端IP地址 * @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字 * @return mixed */function get_cli ...

  4. OAF页面集成条形码或者二维码

    OAF页面集成条形码 OAF生成条形码 OAF页面集成二维码跟这个类似,生成二维码需要以下jar包,zxing-core.jar, zxing-javase.jar,可自行去maven下载. 代码如下 ...

  5. mysql 查询某一主键在那些表中中被设置为外键了

    use information_schema; show tables; select * from KEY_COLUMN_USAGE where COLUMN_NAME='areaid';

  6. IOS7 UI设计的十大准则

    陈子木 iOS7 的用户界面设计比以往更卓越,并为用户提供了更具吸引力的独特体验,带来更大的机遇.在正式写代码之前,认真考虑UI设计是否符合这十条设计准则,可以提高App的可用性与吸引力.如果要更深入 ...

  7. Apollo配置中心介绍

    参考链接:https://github.com/ctripcorp/apollo/wiki/Apollo%E9%85%8D%E7%BD%AE%E4%B8%AD%E5%BF%83%E4%BB%8B%E7 ...

  8. app.jsNodejs启动测试服务

    'use strict'; var express = require('express');var app = express('');var fs = require('fs'); app.get ...

  9. 封装ajax函数

    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title> ...

  10. 快速切题 sgu 111.Very simple problem 大数 开平方 难度:0 非java:1

    111.Very simple problem time limit per test: 0.5 sec. memory limit per test: 4096 KB You are given n ...