# 9. Palindrome Number https://leetcode.com/problems/subarray-product-less-than-k/ ###### Easy ##### Description > Given an integer x, return true if x is palindrome integer. > > An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. ##### Example > Input: x = 121 > Output: true > Input: x = -121 > Output: false > Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. ##### Solution ```python= class Solution: def isPalindrome(self, x: int) -> bool: if x < 0 or (x % 10 == 0 and x != 0): return False target = x rev = 0 while x > 0: pop = x % 10 x = int(x/10) rev = rev * 10 + pop return target == rev ``` ##### Tips * 反轉數字後判斷是否一樣