c# solution, O(1) runtime, without recursion


  • 0
    M

    public int AddDigits(int num) {
    if (num == 0) return 0;
    int mod = num % 9;
    return mod == 0 ? 9 : mod;
    }


Log in to reply
 

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