Skip to content

Commit

Permalink
Create isPalindrome.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudeNi authored Oct 1, 2022
1 parent a9126c1 commit c3274f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions leetcode/python/isPalindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
Given an integer x, return true if x is palindrome integer.
An integer is a palindrome when it reads the same backward as forward.
"""
if x < 0:
return False
rev = list(str(x))
rev.reverse()
rev = int("".join(rev))
if x == rev:
return True
return False

0 comments on commit c3274f7

Please sign in to comment.