public boolean isPalindrome(long x) {
if (x < 0 || (x % 10 == 0 && x != 0)) {
return false;
}
long tempNum = 0;
while (x > tempNum) {
tempNum = tempNum * 10 + x % 10;
x /= 10;
}
return x == tempNum || x == tempNum / 10;
}
O(logN),O(1)
O(logN),O(logN)
O(N),O(1)
O(N),O(logN)