Palindrome Number problem
Vijay Kumar
Full Stack Developer | Big Data Enthusiast | PHP | Python | E-Learning Developer
Leetcode problem: https://leetcode.com/problems/palindrome-number/
Notes: It ain't much but it's honest work. Cast the int into a string. Reverse the string. Compare the reversed string to the original int that was cast. If the two are same then the original int was a palindrome otherwise it wasn't.
Solution:
class Solution:
def isPalindrome(self, x: int) -> bool:
string_x = str(x)
reversed_string_x = string_x[::-1]
if string_x == reversed_string_x:
return True
else:
return False