10-line accepted C code


  • 0
    S

    I think the answer of the reversed integer question can solve this question very easily .
    '''
    bool isPalindrome(int x) {
    int temp = x;
    long long val = 0;
    do
    {
    val = val * 10 + temp % 10;
    temp /= 10;
    } while (temp);
    if (val == x) return true;
    else return false;
    }
    '''


Log in to reply
 

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