Determine whether an integer is a palindrome. Do this without extra space.
Could negative integers be palindromes? (ie, -1) ——NO!
public class Solution {
public boolean isPalindrome(int x) {
int t = x;
int num = 0;
if (x < 0){
return false;
}
while (x != 0){
if (num > Integer.MAX_VALUE){
return false;
}
num *= 10;
num += x % 10;
x /= 10;
}
if (num == t){
return true;
}
else{
return false;
}
}
}