题目:
题解:
step1:如果是负数,则一定不是回文数
step2:采用双指针的思想,一个指针从头开始,一个指针从尾开始,则如果出现不相等,则不是回文数
代码:
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0:
return False
x = str(x)
low = 0
high = len(x)-1
while low < high:
if x[low] != x[high]:
return False
low+=1
high-=1
return True