class Solution {
public:
bool isPalindrome(int x) {
if(x<0 (x!=0 &&x%10==0)) return false;
int sum=0;
while(x>sum)
{
sum = sum*10+x%10;
x = x/10;
}
return (x==sum)(x==sum/10);
}
};
An easy c++ 8 lines code (only reversing till half and then compare)

This is my code not being involved in extra space and math algorithm, but looks stupid! class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ strN = str(x) n = len(strN) i = 0 j = n  1 while(i <= j): if(strN.__getitem__(i) != strN.__getitem__(j)): return False i += 1 j = 1 return True