Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created September 17, 2019 23:40
Show Gist options
  • Save DataSolveProblems/615b44150c8a0a6b2a9e403ab8165a64 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/615b44150c8a0a6b2a9e403ab8165a64 to your computer and use it in GitHub Desktop.
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