class Solution {
public:
bool isPalindrome(int x) {
if(x<0||(x%10==0&&x!=0)) return false;
int tmp=x;
long rev=0; //整数反转可能溢出,保护一下
while(x!=0){
rev=rev*10+x%10;
x/=10;
}
return tmp==rev;
}
};