Thanks to visit codestin.com Credit goes to github.com
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 9c2fc63 commit 1cd8f3aCopy full SHA for 1cd8f3a
0009.leetcode-isPalindrome-回文数/main.go
@@ -6,6 +6,7 @@ package main
6
7
import (
8
"fmt"
9
+ "strconv"
10
)
11
12
func main() {
@@ -14,5 +15,18 @@ func main() {
14
15
}
16
17
func isPalindrome(x int) bool {
-
18
+ if x < 0 {
19
+ return false
20
+ }
21
+ if x < 10 {
22
+ return true
23
24
+ s := strconv.Itoa(x)
25
+ length := len(s)
26
+ for i := 0; i <= length/2; i++ {
27
+ if s[i] != s[length-1-i] {
28
29
30
31
32
0 commit comments