18 lines
522 B
Python
18 lines
522 B
Python
class Solution:
|
|
def isPalindrome(self, x: int) -> bool:
|
|
res = [xx for xx in str(x)]
|
|
if len(res) == 1:
|
|
return True
|
|
i, j = 0, len(res) - 1
|
|
while i < j/2:
|
|
if res[i] != len(res) / 2:
|
|
return False
|
|
i += 1
|
|
j -= 1
|
|
return True
|
|
|
|
print(Solution().isPalindrome(x=121))
|
|
print(Solution().isPalindrome(x=-121))
|
|
print(Solution().isPalindrome(x=10))
|
|
print(Solution().isPalindrome(x=0))
|
|
print(Solution().isPalindrome(x=1000030001))
|