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