lc-go/solutions/0/q9/solution.go

19 lines
347 B
Go

// Package q9 implements a solution for https://leetcode.com/problems/palindrome-number/
package q9
import "strconv"
func isPalindrome(x int) bool {
if x < 0 {
return false
}
str := strconv.FormatInt(int64(x), 10)
for i := range len(str) / 2 {
if str[i] != str[len(str)-1-i] {
return false
}
}
return true
}
var _ = isPalindrome