Determine whether an integer is a palindrome. Do this without extra space.
Some hints:
public boolean isPalindrome(int x) {
if (x < 0) {
return false;
}
if (x >= 0 && x < 10) {
return true;
}
int d = 1;
while (x / d >= 10) {
d *= 10;
}
while (x != 0) {
if (x % 10 != x / d) {
return false;
}
x = x % d / 10;
d /= 100;
}
return true;
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。