algos_and_structures/leetcode/array_9_palindrome_number/my_solution.py
2024-11-02 14:03:30 +03:00

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))