Determine whether an integer is a palindrome. Do this without extra space.
确认一个整数是否是回数。
例如:1234321为回数,12345不是。
分析:这个题其实考查的核心还是整数反转,如果一个整数反转后与反转前相同,则为回数。java代码如下:
class Solution { public boolean isPalindrome(int x) { int a = 0, b = x; while(b > 0){ a = a * 10 + b % 10; b /= 10; } if(a == x) return true; else return false; } }