Skip to content

Commit ec6a78e

Browse files
author
Fei
committed
palindromeNumber
1 parent 7335653 commit ec6a78e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

palindromeNumber.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def isPalindrome(self, x: int) -> bool:
3+
if (x < 0 or (x % 10 == 0 and x != 0)):
4+
return False
5+
rev = 0
6+
while (x > rev):
7+
rev = rev * 10 + x % 10
8+
x = x // 10
9+
return x == rev or x == rev // 10

0 commit comments

Comments
 (0)