Determine whether an integer is a palindrome. Do this without extra space.
class Solution {
public:
bool isPalindrome(int x) {
int d = x;
int a = 0;
if (x >= 0)
while (x != 0) {
a = x % 10 + a * 10;
x /= 10;
}
else
while (x != 0) {
a =- x % 10 + a * 10;
x /= 10;
}
if (a == d) return true;
else return false;
}
};