Determine whether an integer is a palindrome. Do this without extra space.
负数不是回文!
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0)
return false;
vector<int> vec;
do{
int temp = x % 10;
vec.push_back(temp);
x /= 10;
} while (x);
for (int i = 0; i < vec.size() / 2; ++i){
if (vec[i] != vec[vec.size() - 1 - i])
return false;
}
return true;
}
};