class Solution {
public:
bool isPalindrome(int x) {
if (x < 0) {
return false;
}
if (x < 10) {
return true;
}
long long int sum = 0;
int tmp = x;
while (tmp) {
sum = sum * 10 + tmp % 10;
tmp /= 10;
}
return (sum == x);
}
};
class Solution {
public:
bool isPalindrome(int x) {
if ((x < 0) || (x % 10 == 0 && x != 0)) {
return false;
}
int rev = 0;
while (x > rev) {
rev = rev * 10 + x % 10;
x /= 10;
}
return (x == rev) || (x == rev / 10);
}
};