https://leetcode.com/problems/palindrome-number/
understanding:
题目原意是要我们用数学的办法去coding,而不是转化成string。但转化成string也可以通过。
my code:
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x >=0:
x = str(x)
else:
return False
i = 0
j = len(x) - 1
while j > i:
if x[i] == x[j]:
i += 1
j -= 1
else:
break
if j <= i:
return True
else:
return False