every blog every motto: You will never know unless you try
0. 前言
生活好难,再坚持坚持!
1. 字符串
1.1 题目
1.2 题解
class Solution:
def isPalindrome(self, s: str) -> bool:
if len(s)<=1 :
return True
else:
left = 0
right = len(s)-1
while(left<right):
while(left<right and not s[left].isalnum()):
left += 1
while(left<right and not s[right].isalnum()):
right -= 1
if left < right:
if s[left].lower() != s[right].lower():
return False
else:
left += 1
right -= 1
return True