Determine whether an integer is a palindrome. Palindrome correct order (from left to right) and reverse (right to left) reading is the same integer.
Example 1 : Input: 121 Output: to true Example 2 : Input: -121 Output: to false interpretation: read from left to right, is -121. Reading from right to left, as 121- . So it is not a palindrome number. Example 3 : Input: 10 Output: to false interpretation: reading from right to left, to 01. So it is not a palindrome number.
public boolean isPalindrome(int x) { if (x < 0){ return false; } int temp = x; int result = 0; while(x != 0) { int pop = x % 10; result = result * 10 + pop; x /= 10; } return temp == result; }