Reverse the number and compare it with the original one.
class Solution {
public:
bool isPalindrome(int x) {
int old_x=x;
int new_x=0;
while(x>0)
{
if((INT_MAX-x%10)/10<new_x)
return false;
new_x=new_x*10+x%10;
x/=10;
}
return new_x==old_x;
}
};