15 lines
471 B
Python
15 lines
471 B
Python
class Solution:
|
|
def isPalindrome(self, x: int) -> bool:
|
|
s = str(x)
|
|
if len(s) % 2 == 0:
|
|
mid = len(s) // 2 - 1
|
|
for i in range(mid):
|
|
if s[i] != s[len(s) - i - 1]:
|
|
return False
|
|
return True
|
|
else:
|
|
mid = len(s) // 2
|
|
for i in range(mid):
|
|
if s[i] != s[len(s) - i - 1]:
|
|
return False
|
|
return True |