Determine whether an integer is a palindrome. Do this without extra space.
class Solution {
public boolean isPalindrome(int x) {
int a = x, h = 1;
if (a < 0) return false;//排除负数
while (a / h >= 10) {//123321
h = h * 10; //判断a是几位数
}
while (a > 0) {
if (a / h != a % 10) return false;
a = a % h;
a = a / 10;
h = h / 100;
}
return true;
}
}