How to judge palindromes in LeetCode
LeetCode how to judge the number of palindrome, I believe that many people without experience can do nothing about this, this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.
Idea 1: Turn to character string to determine whether the original character string is consistent with the inverted character string
When a palindrome number is converted into a character string, it has the same characteristics as the original character string and the inverted character string, while a non-palindrome number does not have this characteristic, so it can be judged whether it is a palindrome number in this way. This idea is easier to understand, and you can find that negative numbers are not palindrome numbers (such as: -11 read from the right is 11-), so you can return negative numbers to false first, avoiding more calculations later.
class Solution: def isPalindrome(self, x: int) : if(x