Determine whether an integer is a palindrome. Do this without extra space.
Have you met this question in a real interview?
Yes
No
class Solution {
public:
bool isPalindrome(int x) {
if(x<0) return false;
int radix = 1;
while(x/radix >= 10)
radix*=10;
while(x){
int left = x/radix;
int right = x%10;
if(left!=right)
return false;
x =(x-left*radix)/10;
radix /= 100;
}
return true;
}
};