class Solution {
public boolean isPalindrome(int x) {
if (x < 0) {
return false;
} else if (x == 0) {
return true;
} else {
String num = String.valueOf(x);
int start = 0;
int end = num.length() - 1;
while (start < end) {
if (num.charAt(start) != num.charAt(end)) {
return false;
}
start += 1;
end -= 1;
}
}
return true;
}
}
04-29
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交