mycode   9.62%

class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
res = ''
s = s.lower()
alphanum = string.ascii_lowercase + string.digits
for i in s:
if i in alphanum:
res += i
return res == res[::-1]

注意以下陷阱

class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
res = s = [i for i in s if i != ' ']
print(s)
res.reverse()
print(s)
print(res)
return res == s

参考

主要是如何简单的判断是否为字符数组

class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s="".join(e for e in s if e.isalnum()).lower()
return s == s[::-1]

最新文章

  1. (转载)solr时区问题解决方案
  2. Ubuntu 14.10安装SecureCRT 7.3(转)
  3. Spring简介和基础
  4. Supervisor 的配置与使用
  5. 【转】ubuntu下自动挂载硬盘分区
  6. win10开始菜单打不开的解决办法
  7. 一个web应用的诞生(8)--博文发布
  8. git常用命令总结--廖雪峰老师Git教程命令总结
  9. Linux:Red Hat系统的安装
  10. 百度ip定位城市接口调用
  11. 深入理解HashMap和CurrentHashMap
  12. AttributeError: 'list' object has no attribute 'keys'
  13. Mybatis特殊值Enum类型转换器-ValuedEnumTypeHandler
  14. 从JSF看XPages的优点
  15. 用 Fiddler 来弥补 Chrome Network 的小缺点
  16. mysql中and 和 or 联合使用
  17. LCA在线算法详解
  18. 轮播图jQuery
  19. error MSB3552: Resource file "**/*.resx" cannot be found. [/ConsoleApp1.csproj]
  20. 华为手机不能连接android studio进行调试的解决办法

热门文章

  1. git解决pre-commit hook failed的问题
  2. 制作嵌入式linux内核
  3. CentOS6.5安装zabbix3.0
  4. Android九宫格解锁有多少种姿势
  5. GO (待更新)
  6. Docker从0开始之部署一套2048
  7. mysql创建函数槽点
  8. sql语言积累
  9. 【LOJ#536】「LibreOJ Round #6」花札
  10. spark读取hbase(NewHadoopAPI 例子)