s4553711
7/5/2017 - 2:50 PM

9.cpp

class Solution {
public:
    bool isPalindrome(int x) {
        if (x == 0) return true;
        if (x < 0 || x % 10 == 0) return false;
        int r = 0;
        while(x>r) {
            r = r*10 + x%10;
            x /= 10;
        }
        return (x==r || x==r/10);
    }
};