my c solution


  • 0
    S
    bool isPalindrome(int x) {
        int y, d;
        if (x < 0)
        {
            return false;
        }
        if (x < 10)
        {
            return true;
        }
        d = x % 10;
        if (!d)
        {
            return false;
        }
        y = d;
        x /= 10;
        if (x == y)
        {
            return true;
        }
        while (x > y)
        {
            d = x % 10;
            x /= 10;
            if (x == y)
            {
                return true;
            }
            y = y * 10 + d;
        }
        return x == y;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.