Determine whether an integer is a palindrome. Do this without extra space.
1.负数直接返回false;
2.正书如果是回文数字,头尾颠倒之后相等;
public boolean isPalindrome(int x) {
if(x < 0) {
return false;
}
int sum = 0;
int k = x;
while(k/10 != 0) {
sum = sum*10 + k%10;
k = k/10;
}
sum = sum*10 + k;
if(sum == x) {
return true;
}else {
return false;
}
}