We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1466f5 commit 1aeda69Copy full SHA for 1aeda69
go/valid_palindrome.go
@@ -4,21 +4,19 @@ package main
4
import "unicode"
5
6
func isPalindrome(s string) bool {
7
- r := []rune(s)
8
- for i, j := 0, len(r)-1; i < j; {
9
- if !(unicode.IsLetter(r[i]) || unicode.IsDigit(r[i])) {
+ sRunes := []rune(s)
+ for i, j := 0, len(s)-1; i < j; {
+ if !(unicode.IsDigit(sRunes[i]) || unicode.IsLetter(sRunes[i])) {
10
i++
11
continue
12
}
13
- if !(unicode.IsLetter(r[j]) || unicode.IsDigit(r[j])) {
+ if !(unicode.IsDigit(sRunes[j]) || unicode.IsLetter(sRunes[j])) {
14
j--
15
16
17
-
18
- if unicode.ToLower(r[i]) != unicode.ToLower(r[j]) {
+ if unicode.ToLower(sRunes[i]) != unicode.ToLower(sRunes[j]) {
19
return false
20
21
22
23
24
0 commit comments