class Solution:
def isPalindrome(self,x:int) ->bool:
if x<0 or (x%10 ==0 and x!=0):
return False
revertedNumber =0
while x> revertedNumber:
revertedNumber = revertedNumber *10 +x%10
x //=10
return x == revertedNumber or x == revertedNumber//10
class Solution:
? ? ? ? def isPalindrome(self,x:int) ->bool:
? ? ? ? ? ? ? ? if x<0 or (x%10 ==0 and x!=0):
? ? ? ? ? ? ? ? ? ? ? ? return False
? ? ? ? ? ? ? ? revertedNumber =0
? ? ? ? ? ? ? ? while x>revertedNumber:
? ? ? ? ? ? ? ? ? ? ? ? revertedNumber = revertedNumber*10 +x%10
? ? ? ? ? ? ? ? ? ? ? ? x//=10
? ? ? ? ? ? ? ? return x == revertedNumber or x == revertedNumber//10
class Solution:
def isPalindrome(self,x:int) -> bool:
if x<0 or (x%10==0 and x!=0):
return False
revertedNumber =0
while x>revertedNumber:
revertedNumber = revertedNumber
x //=10
return x == revertedNumber or x
?
class Solution:
def isPalindrome(self, x: int) -> bool:
y = str(x)
return x >= 0 and y == y[::-1]
class Solution:
def isPalindrome(self,x:int) -> bool:
y= str(x)
return x>=0 and y ==y[::-1]
|