Skip to content

Commit

Permalink
Create palindrome-num.py
Browse files Browse the repository at this point in the history
checks if number is a palindrome by casting to str and manipulating. There are non cast methods that I have not implemented here.
  • Loading branch information
gabedonnan authored Jan 12, 2023
1 parent 9f9b8e2 commit ebbd5e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions palindrome-num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""

temp = str(x) #String solution
for i in range(len(temp) // 2):
if temp[i] != temp[-(i+1)]:
return False
return True

0 comments on commit ebbd5e2

Please sign in to comment.