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;
        }
        
    }
}

0 Comments

Leave a reply

* Your email/mobile address will not be published. required fields are marked.

* Email and mobile number will be verified before publishing the comments.

Name *
Email *
Mobile