2019-05-19LeetCode125. 验证回文串
2019-05-19 本文已影响0人
mztkenan
class Solution:
def isPalindrome(self, s: str) -> bool:
low,high=0,len(s)-1
while(low<=high):
while(not s[low].isalnum() and low<high):
low+=1
while(not s[high].isalnum() and low<high):
high-=1
if(s[low].lower()!=s[high].lower()):return False
low+=1
high-=1
return True
1.str.lower() str.isalnum()
2." " 边界条件,中间的循环会越界
3.".a" 循环条件没控制好的话 ,这题主要问题还是边界条件,指针相碰