Given an integer x, return true if x is palindrome integer.
Given an integer x, return true if x is palindrome integer. (JAVA)
Input: x = 515
Output: true
Input: x = -515
Output: false
class Palindrome {
public boolean isPalindrome(int x) {
if(x<0)
{
return false;
}
int num=0;
int temp=x;
while(x!=0)
{
int r=x%10;
num=num*10+r;
x=x/10;
}
if(num==temp)
{
return true;
}
else{
return false;
}
}
}