4ms solution with c language


  • 0
    L
    int addDigits(int num) {
        if (num == 0)
    	    return 0;
        num %= 90;
        if ((num / 10 + num % 10) % 9 != 0)
    	    return (num / 10 + num % 10) % 9;
        return 9;
    }

Log in to reply
 

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