125. Valid Palindrome
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.
Given a string s, return true if it is a palindrome, or false otherwise.
简单说就是检查是不是回文
以下golang code
func isPalindrome(s string) bool {
slice := []int{}
for _, c := range s {
if c >= 97 && c <= 122 {
slice = append(slice, int(c))
continue
}
if c >= 65 && c <= 90 {
slice = append(slice, int(c+32))
}
if c >= 48 && c <= 57 {
slice = append(slice, int(c))
continue
}
}
i := 0
j := len(slice) - 1
for i < j {
if slice[i] == slice[j] {
i += 1
j -= 1
continue
}
return false
}
return true
}
不得不说golang在字串处理方面好像有点麻烦
资料结构也有点没那么强大的感觉