LeetCode 9. Palindrome Number
Description
Determine whether an integer is a palindrome. Do this without extra space.
class Solution {
public boolean isPalindrome(int x) {
String s = Integer.toString(x);
int i = 0;
int j = s.length() - 1;
char[] chars = s.toCharArray();
while (i < j) {
if (chars[i] != chars[j]) {
return false;
}
else {
i++;
j--;
}
}
return true;
}
}