class Solution {
public:
bool isPalindrome(int x) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (x < 0)
return false;
return isPalindromeHelper(x, x);
}
bool isPalindromeHelper(int x, int &y) {
if (x == 0)
return true;
if (isPalindromeHelper(x / 10, y) && (x % 10 == y % 10)) {
y /= 10;
return true;
}
return false;
}
};
Determine whether an integer is a palindrome. Do this without extra space.