Created
February 25, 2019 13:15
-
-
Save mylons/e29cad829791039a08944288720294f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def int_to_array(x: int) -> List[int]: | |
result = [] | |
while x > 0: | |
tmp = x % 10 | |
result.append(tmp) | |
x = int((x - tmp) / 10) | |
return result | |
class Solution: | |
def isPalindrome(self, x: int) -> bool: | |
if x < 0: | |
return False | |
arr = int_to_array(x) | |
end = len(arr) - 1 | |
start = 0 | |
while start < end: | |
if arr[start] == arr[end]: | |
start += 1 | |
end -= 1 | |
else: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment