标签:style blog color io ar for sp div on
1、注意空字符串的处理;
2、注意是alphanumeric字符;
3、字符串添加字符直接用+就可以;
1 class Solution: 2 # @param s, a string 3 # @return a boolean 4 def isPalindrome(self, s): 5 ret = False 6 s = s.lower() 7 ss = "" 8 for i in s: 9 if i.isalnum(): 10 ss += i 11 h = 0 12 e = len(ss)-1 13 while(h<e): 14 if(ss[h] == ss[e]): 15 h += 1 16 e -= 1 17 else: 18 break 19 if h>=e: 20 ret = True 21 return ret
标签:style blog color io ar for sp div on
原文地址:http://www.cnblogs.com/CheeseZH/p/4029951.html