--- tags: data_structure_python --- # Palindrome Number <img src="https://img.shields.io/badge/-easy-brightgreen"> Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. <ins>**Example 1:**</ins> >Input: 121 >Output: true <ins>**Example 2:**</ins> >Input: -121 >Output: false >Explanation: From left to right, it reads -121. From right to left, it >becomes 121-. Therefore it is not a palindrome. <ins>**Example 3:**</ins> >Input: 10 >Output: false >Explanation: Reads 01 from right to left. Therefore it is not a palindrome. **Follow up:** Coud you solve it without converting the integer to a string? ## Solution ```python= class Solution: def isPalindrome(self, x: int) -> bool: if x < 0 or x > 2**31 -1: return False else: tmp = x res = 0 while tmp != 0: res = res * 10 + (tmp % 10) tmp = tmp // 10 return x == res ```