Created
September 17, 2019 23:40
-
-
Save DataSolveProblems/615b44150c8a0a6b2a9e403ab8165a64 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Solution: | |
def isPalindrome(self, x: int) -> bool: | |
n = len(str(x)) // 2 | |
if len(str(x)) % 2 != 0: | |
n = len(str(x)) // 2 | |
return str(x)[:n] == str(x)[:n:-1] | |
elif len(str(x)) % 2 == 0: | |
return str(x)[:n] == str(x)[n:][::-1] | |
else: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment