题目描述
方法一:转换为字符串
class Solution: def isPalindrome(self, x: int) -> bool: if x<0: return False else: y=str(x)[::-1] return y==str(x)
方法二;数字反转
class Solution: def isPalindrome(self, x: int) -> bool: if x<0: return False a,res=x,0 while x: x,mod = x//10,x%10 res=res*10+mod return a == res