回文数
Leetcode - 9 Palindrome Number (Easy)
题目描述:判断一个整数是否为回文数。
Input: -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
public boolean isPalindrome(int x) {
int rev = 0;
int inputX = x;
while(x > 0){
rev = rev * 10 + x % 10;
x = x / 10;
}
return inputX == rev;
}