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. EFS 你应该知道的事

    需要备份或者还保留这个路径 %USERPROFILE%\AppData\Roaming\Microsoft\Crypto\RSA certmgr.msc 个人证书导出你开始使用EFS加密后的证书 ci ...

  2. Yet Another Ball Problem CodeForces - 1118E (简单构造)

    大意: 求构造n个pair, 每个pair满足 对于每k组, 让$b_i$为$[1,k]$, $g_i$循环右移就好了 int n, k, cnt; int main() { scanf(" ...

  3. Necklace CodeForces - 613C (构造)

    链接 大意: 给定n种珠子, 第i种有$a_i$个, 求将珠子穿成项链, 使得能使切开后的项链回文的切口尽量多 若有一种以上珠子为奇数, 显然不能为回文, 否则最大值一定是$gcd(a_1,a_2,. ...

  4. ansible-playbook快速入门填坑

    参考另外一篇文章 http://blog.51cto.com/weiweidefeng/1895261 when条件 参考http://blog.51cto.com/breezey/1757593 安 ...

  5. python 小练习 10

    给你一个十进制数a,将它转换成b进制数,如果b>10,用大写字母表示(10用A表示,等等) a为32位整数,2 <= b <= 16 如a=3,b = 2, 则输出11 AC: di ...

  6. HDOJ1001

    #include<iostream> using namespace std; int main() { long long n; while(cin >> n) { cout ...

  7. 微信小程序--登录流程梳理

    前言 微信小程序凡是需要记录用户信息都需要登录,但是也有几种不同的登录方式,但是在小程序部分的登录流程是一样的.之前就朦朦胧胧地用之前项目的逻辑改改直接用了,这个新项目要用就又结合官方文档重新梳理了下 ...

  8. JAVA并行程序基础

    JAVA并行程序基础 一.有关线程你必须知道的事 进程与线程 在等待面向线程设计的计算机结构中,进程是线程的容器.我们都知道,程序是对于指令.数据及其组织形式的描述,而进程是程序的实体. 线程是轻量级 ...

  9. 用Maven创建第一个web项目

    http://www.cnblogs.com/leiOOlei/p/3361633.html 一.创建项目 1.Eclipse中用Maven创建项目 上图中Next 2.继续Next 3.选maven ...

  10. windows创建窗口、关闭窗口流程

    NC,即 non-client 区域,包括标题栏.窗口边框.最大.最小按钮.滚动条等. 一.在调用Windows的::CreateWindowEx函数创建窗口时,一般会先发出 WM_NCCREATE消 ...