Skip to content

Commit a0948b4

Browse files
author
Franklin Qin
authored
Create isPalindrome.py
1 parent 5d5c81a commit a0948b4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Franklin/isPalindrome.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# lc problem 9
2+
# Determine whether an integer is a palindrome.
3+
4+
class Solution(object):
5+
def isPalindrome(self, x):
6+
"""
7+
:type x: int
8+
:rtype: bool
9+
"""
10+
if (x<0 or ()):
11+
return False
12+
rev = 0
13+
while (x!=0):
14+
rev = rev*10 + x%10
15+
x = x/10
16+
return (x==rev or x==rev/10)

0 commit comments

Comments
 (0)