8ms C++ solution


  • 1
    A
    class Solution {
    public:
        int addDigits(int num) {        
            if(num/10 == 0){
                return num%10;
            }
            else{
                num = addDigits(num/10) + num%10;
                return addDigits(num);
            }        
        }
    };

Log in to reply
 

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