【leetcode❤python】 125. Valid Palindrome
#-*- coding: UTF-8 -*-
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s=s.lower()
if s==None:return False
isPalindrome1=[]
isPalindrome2=[]
for c in s:
if (c>='a' and c<='z') or (c>='0' and c<='9'):
isPalindrome1.append(c)
for i in range(len(s))[::-1]:
if (s[i]>='a' and s[i]<='z') or (s[i]>='0' and s[i]<='9'):
isPalindrome2.append(s[i])
return isPalindrome2==isPalindrome1
sol=Solution()
print sol.isPalindrome("ab")
【leetcode❤python】 125. Valid Palindrome的更多相关文章
- 【leetcode❤python】 20. Valid Parentheses
#-*- coding: UTF-8 -*-#利用栈的思想#如果输入的左测扩则入栈,如果输入为右侧扩,判断其是否与当前栈顶配对,如果匹配则删除这一对,否则return False#'(', ')', ...
- 【leetcode❤python】 36. Valid Sudoku
#-*- coding: UTF-8 -*-#特定的九个格内1-9的个数至多为1#依次检查每行,每列,每个子九宫格是否出现重复元素,如果出现返回false,否则返回true.class Solutio ...
- 【leetcode❤python】409. Longest Palindrome
#-*- coding: UTF-8 -*- from collections import Counterclass Solution(object): def longestPalindro ...
- 【leetcode❤python】242. Valid Anagram
class Solution(object): def isAnagram(self, s, t): if sorted(list(s.lower()))==sorted(list ...
- 【LeetCode】125. Valid Palindrome 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 列表生成式 正则表达式 双指针 日期 题目地址:https:/ ...
- 【一天一道LeetCode】#125. Valid Palindrome
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- 【LeetCode】125. Valid Palindrome
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- 【leetcode❤python】Sum Of Two Number
#-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...
- 【leetcode❤python】 234. Palindrome Linked List
#-*- coding: UTF-8 -*-class Solution(object): def isPalindrome(self, head): ""&q ...
随机推荐
- imx6 uboot saveenv fail
uboot设置环境变量之后,不能保存在EMMC中,出现错误. MX6SDL SABRESD U-Boot > saveenv Saving Environment to SPI Flash... ...
- ActiveMQ简介
ActiveMQ 1.ActiveMQ是什么ActiveMQ是Apache推出的一款开源的完全支持JMS1.1和J2EE1.4规范的JMS Provider实现的消息中间件(Message Orien ...
- 恢复 混淆后的 stacktrace 文件
./tools/proguard/bin/retrace.sh /Users/admin/Downloads/ProguardSample/app/build/outputs/mapping/rele ...
- 在 Apache Ant中设置Proxy服务器
<target name="proxy"> <property name="proxy.host" value="https://m ...
- iOS计算完整文字高度(适应iOS 10)
动态计算文字的高度:(切记LineSapcing>=2,不然会显示不全) +(CGSize) boundingALLRectWithSize:(NSString*) txt Font:(UIFo ...
- webapi post 请求多个参数
Some programmers are tring to get or post multiple parameters on a WebApi controller, then they will ...
- 【转载】jQuery动画连续触发、滞后反复执行解决办法
转载: http://www.cnblogs.com/yuejin/archive/2012/12/18/2822595.html jQuery中slideUp .slideDown.animate等 ...
- C# Linq 交集、并集、差集、去重
using System.Linq; List<string> ListA = new List<string>(); List<string> L ...
- [Silverlight]监听指定控件(FrameworkElement)的依赖属性(DependencyProperty)的更改
前言 转载请注明出处:http://www.cnblogs.com/ainijiutian 最近在silverlight项目使用Telerik的控件,遇到一个问题.就是使用RadBusyIndicat ...
- 分享一个延迟加载图片的JS
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...