public boolean isPalindrome(int x) {
        //if nagetive
        if (x < 0) {
            return false;
        }
        //0~9 is palindrome
        if (x < 10) {
            return true;
        }
        //10, 100, etc. are not palindrome
        if (x % 10 == 0) {
            return false;
        }

        int r = 0;
        //calculate the number from the end.
        //if in palindrome, x will equal to r or x == r/10
        while (x > 0 && x > r) {
            r = r * 10;
            r = r + x % 10;
            x = x / 10;
        }

        if (x != 0 && (x == r || x == r / 10)) {
            return true;
        } else {
            return false;
        }
    }