Don't convert the number into String
public class Solution {
public boolean isPalindrome(int x) {
if (x < 0) return false;
//1. get divider
int div = 1;
int number = x;
while (number / div >= 10) {
div = div * 10;
}
System.out.println (div);
// 2. find the palindrom
while (div != 0) {
int first = number / div;
int last = number % 10;
if (first != last)
return false;
number = (number - first * div) / 10;
div = div / 100;
}
return true;
}
}