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