Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
##brute force
class Solution:
def isPalindrome(self, x: int) -> bool:
for i in range(len(str(x))):
x = str(x)
if x[i] != x[len(str(x))-i-1]:
return False
if int(x) < 0:
return False
else:
return True
##bit faster solution
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0:
return False
if str(x) != str(x)[::-1]:
return False
else:
return True