class Solution {
public boolean isPalindrome(int x) {
String xStr=String.valueOf(x);
StringBuffer sb = new StringBuffer(xStr);
sb.reverse();
if(xStr.equals(sb.toString())){
return true;
}
return false;
}
}
class Solution {
public boolean isPalindrome(int x) {
if(x<0)
return false;
int temp=1;
while(x/temp>=10)
{
temp*=10;
}
while(x>0)
{
int left=x/temp;
int right=x%10;
if(left!=right)
{
return false;
}
x=x%temp/10;
temp/=100;
}
return true;
}
}
class Solution {
public boolean isPalindrome(int x) {
if (x < 0 || (x % 10 == 0 && x != 0)) {
return false;
}
int revertedNumber = 0;
while (x > revertedNumber) {
revertedNumber = revertedNumber * 10 + x % 10;
x /= 10;
}
return x == revertedNumber || x == revertedNumber / 10;
}
}