Determine whether an integer is a palindrome. Do this without extra space.
class Solution {
public:
bool isPalindrome(int x) {
if ((x < 0) || (x > 0 && x % 10 == 0))
return false;
char A[100];
int i = 0, j;
while (x != 0) {
A[i++] = x % 10;
x = x / 10;
}
for (j = 0, i; j < i; j++, i--)
if (A[j] != A[i - 1])
return false;
return true;
}
};