```
public boolean isPalindrome(int x) {
if (x < 0)
return false;
int root = (int) Math.sqrt(x);
int temp = x % 10;
while (root / 10 != 0) {
temp = temp * 10 + x / 10 % 10;
x = x / 10;
root = root / 10;
}
return (x == temp || x / 10 == temp);
}
```