leetcode:Valid Palindrome【Python版】
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版】的更多相关文章
- [leetcode]Valid Palindrome @ Python
原题地址:https://oj.leetcode.com/problems/valid-palindrome/ 题意: Given a string, determine if it is a pal ...
- leetcode Valid Palindrome C++&python 题解
题目描写叙述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- [LeetCode] Valid Palindrome 验证回文字符串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode——Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- [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 ...
- LeetCode Valid Palindrome II
原题链接在这里:https://leetcode.com/problems/valid-palindrome-ii/description/ 题目: Given a non-empty string ...
- Leetcode Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode: Valid Palindrome [125]
[题目] Given a string, determine if it is a palindrome, considering only alphanumeric characters and i ...
- LeetCode: Valid Palindrome 解题报告
Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...
- [Leetcode] valid palindrome 验证回文
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
随机推荐
- RabbitMq windows 安装
参考官方网址: http://www.rabbitmq.com/install-windows-manual.html http://www.rabbitmq.com/install-windows. ...
- UVA-10318 Security Panel (DFS+剪枝)
题目大意:求将一个r*c的按钮矩阵由全部为关变成全部为开的最少按扭次数,每按一次开关能作用到的范围不定. 题目分析:开关问题.打眼一看就是BFS+位压缩,但是写出来之后TLE.用DFS不断更新最优解. ...
- Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level
2018-03-23 18:32:21,690 [INFO] [http-nio-11007-exec-2] org.apache.coyote.http11.Http11Processor [Dir ...
- ps -ef |grep xxx 输出的具体含义
ps:将某个进程显示出来 -A 显示所有程序. -e 此参数的效果和指定"A"参数相同. -f 显示UID,PPIP,C与STIME栏位. grep命令是查找 中间的|是管道命令 ...
- 不能将Lnode * 类型的值分配到Lnode * 类型的实体
typedef struct { int data; struct Lnode *next;}Lnode,*LinkList; 这个地方有点问题,因为结构体定义中出现了struct Lnode但 Ln ...
- dubbo的超时重试
dubbo的超时分为服务端超时 SERVER_TIMEOUT 和客户端超时 CLIENT_TIMEOUT.本文讨论服务端超时的情形: 超时:consumer发送调用请求后,等待服务端的响应,若超过ti ...
- java并发编程:线程安全管理类--原子操作类--AtomicLongArray
1.类 AtomicLongArray public class AtomicLongArray extends Object implements Serializable 可以用原子方式更新其元素 ...
- js 数组复制问题
师兄面试回来问个问题,js中数组怎么复制,工作中没遇到,面试也涨见识 了,他给我说了下,太晚没留心,打早起来研究下,写个dom,来看下 代码如下 <!doctype html> <h ...
- 快速切题 poj3026
感受到出题人深深的~恶意 这提醒人们以后...数字后面要用gets~不要getchar 此外..不要相信那个100? Borg Maze Time Limit: 1000MS Memory Lim ...
- c++多态多实例
#include <bits/stdc++.h> using namespace std; class A { public: A() { cout << "构造A& ...