aboutsummaryrefslogtreecommitdiffstats
path: root/9
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-03 07:19:42 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-03 07:19:42 +0000
commitfeeb934df9a55602a0c038f3b73e948c6a6c6e06 (patch)
tree138c57d152575161f6c7452737cb54322f89145a /9
parent1160 (diff)
downloadleetcode-feeb934df9a55602a0c038f3b73e948c6a6c6e06.tar.gz
leetcode-feeb934df9a55602a0c038f3b73e948c6a6c6e06.zip
9,1266
Diffstat (limited to '9')
-rw-r--r--9/main.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/9/main.go b/9/main.go
new file mode 100644
index 0000000..cc44567
--- /dev/null
+++ b/9/main.go
@@ -0,0 +1,23 @@
+package main
+
+import "fmt"
+
+func isPalindrome(x int) bool {
+ if x < 0 {
+ return false
+ }
+ var y int
+ for i := x; i > 0; i /= 10 {
+ y = y*10 + i%10
+ fmt.Println(y)
+ }
+ return x == y
+}
+
+func main() {
+ fmt.Println(isPalindrome(12345678))
+ fmt.Println(isPalindrome(1234321))
+ fmt.Println(isPalindrome(121))
+ fmt.Println(isPalindrome(-121))
+ fmt.Println(isPalindrome(10))
+}