LeetCode第9题 回文数

/*判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。*/


class Solution9 {

public boolean isPalindrome(int x) {
char[] chars = String.valueOf(x).toCharArray();
for (int i = 0; i < chars.length / 2; i++) {
if (chars[i] != chars[chars.length - i - 1]) {
return false;
}
}
return true;
}

}

猜你喜欢

转载自www.cnblogs.com/rainbow-/p/10257071.html