Determine whether an integer is a palindrome. Do this without extra space.
Solution[C++]:
class Solution {
public:
bool isPalindrome(int x) {
if(x < 0)
return false;
int tempX = x;
int x2 = 0;
while(x != 0){
x2 = x2*10 + x%10;
x /= 10;
}
return (x2 == tempX);
}
};