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. python-day33--进程间通信(IPC)

    方式:队列(推荐使用) 一.基本情况 1.可以往队列里放任意类型的数据 2. 队列:先进先出 3. q=Queue(3) #可以设置队列中最多可以进入多少个值,也可以不设置 q.put('first' ...

  2. Leetcode 94

    /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...

  3. Leetcode 74

    class Solution { public: bool searchMatrix(vector<vector<int>>& matrix, int target) ...

  4. Xshell如何设置,当连接断开时保留Session,保留原文字

    Xshell [1]  是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 协议.Xshell 通过互联网到远程主机的安全连接以及它 ...

  5. C# / .NET 在类中使用Server.MapPath

    直接在类中使用 Server.MapPath 会出现错误,这是由于类中不能直接使用 System.Web.UI.Page 的非静态函数造成的.解决方法有两种: 方法一.使类继承System.Web.U ...

  6. ASP.NET简介

    1.什么是ASP.NET? ASP.NET是一套免费的网络架构,是为了构建一个伟大的或者说非常不错的网站或网络应用,并同时使用了一些前端技术,比如说HTML,CSS和JavaScript ASP.NE ...

  7. 87. Scramble String *HARD* 动态规划

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  8. overflow属性-摘自网友

    关于我们 版权声明 网站地图 前端观察 专注于网站前端设计与前端开发 用IE6抢不到火车票的!!! Home 首页 CSS样式之美 Front News前端资讯 JavascriptAjax与JS技术 ...

  9. Get gcc built-in macros using command gcc -dM -E - < /dev/null

    root@vmuser-virtual-machine:/home/vmuser# gcc -dM -E - < /dev/null #define __SSP_STRONG__ 3#defin ...

  10. 3.strcpy使用注意(3)

    void test3(char * str1) { if(str1==NULL) { return; } char string[10]; if(strlen(str1)<=10) { strc ...