题目描述

思路:与数字反转思路一样,可直接解答
class Solution:
def isPalindrome(self, x: int) -> bool:
y = abs(x)
nums = 0
while (y!=0):
num = y%10
nums = nums*10 + num
y = y//10
if x == nums and x>=0:
return True
else:
return False
网友评论