Skip to content

Commit

Permalink
Create 0009-palindrome-number.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AP-Repositories authored Dec 30, 2022
1 parent 2d0e0cc commit 4da7e93
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/0009-palindrome-number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0: return False

div = 1
while x >= 10 * div:
div *= 10

while x:
right = x % 10
left = x // div

if left != right: return False

x = (x % div) // 10
div = div / 100
return True

0 comments on commit 4da7e93

Please sign in to comment.