//根据回文数的特点,只需要翻转一半与另一半进行对比,就可以判断是否是回文数字。publicclassSolution{publicboolIsPalindrome(intx){// Special cases:// As discussed above, when x < 0, x is not a palindrome.// Also if the last digit of the number is 0, in order to be a palindrome,// the first digit of the number also needs to be 0.// Only 0 satisfy this property.if(x<0||(x%10==0&&x!=0)){returnfalse;}intrevertedNumber=0;while(x>revertedNumber){revertedNumber=revertedNumber*10+x%10;x/=10;}returnx==revertedNumber||x==revertedNumber/10;}}