String 有效回文while循环
第一版String 有效回文while循环,string,while-loop,palindrome,String,While Loop,Palindrome,第一版 class Solution(object): def isPalindrome(self, s): f,l = 0,len(s)-1 while f<l: while **f<l** and not s[f].isalnum(): f+=1 while **f<l** and not s[l].isalnum(): l
class Solution(object):
def isPalindrome(self, s):
f,l = 0,len(s)-1
while f<l:
while **f<l** and not s[f].isalnum():
f+=1
while **f<l** and not s[l].isalnum():
l-=1
if s[f].lower()!=s[l].lower():
return False
f+=1
l-=1
return True
类解决方案(对象):
def isPalindrome(自身):
f、 l=0,len(s)-1
而f
class Solution(object):
def isPalindrome(self, s):
f,l = 0,len(s)-1
while f<l:
while not s[f].isalnum():
f+=1
while not s[l].isalnum():
l-=1
if s[f].lower()!=s[l].lower():
return False
f+=1
l-=1
return True