your runtime beats 100.00% of csubmissions.


  • -1
    C

    int addDigits(int num) {
    int s=0;
    while(num)
    {
    s+=num%10;
    num/=10;
    if(s>=10)
    {
    s-=9;
    }
    }
    return s;
    }


  • -1
    E

    what if the input is '199'? after the 'while',the result would be '19',19-9=10 ,obiviously it is not correct .


Log in to reply
 

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