Check if number is palindrome
Java
Easy
4 views
Problem Description
Task: return true if integer reads same from left to right.
Output Format
Return value
Constraints
Handle negative as not palindrome.
Official Solution
static boolean isPalindromeInt(int x){if(x<0) return false;int orig=x;int rev=0;while(x>0){rev=rev*10+(x%10);x/=10;}return rev==orig;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!