Determine whether an integer is a palindrome. Do this without extra space.
回文数,这里将其转换成string,就很容易处理了。
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x<0:
return False
else:
x = str(x)
for i in range(len(x)/2):
if x[i] != x[len(x)-1 - i]:
return False
return True