```
class Solution(object):
# def isPalindrome(self, x):
# """
# :type x: int
# :rtype: bool
# """
# ### With extra space
# if x < 0:
# return False
# y = int(str(x)[::-1])
# if y == x:
# return True
# return False
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x < 0:
return False
y = self.reverseInt(x)
if y == x:
return True
return False
def reverseInt(self, x):
answer = 0
while x != 0:
digit = x%10
x = x/10
answer = answer*10 + digit
return answer
```