题目:
题解:
func isPalindrome(s string) bool {
s = strings.ToLower(s)
left, right := 0, len(s) - 1
for left < right {
for left < right && !isalnum(s[left]) {
left++
}
for left < right && !isalnum(s[right]) {
right--
}
if left < right {
if s[left] != s[right] {
return false
}
left++
right--
}
}
return true
}
func isalnum(ch byte) bool {
return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')
}