C++ one line solution


  • 0
    F

    the max integer is 2147483647

    class Solution {
    public:
        int addDigits(int num) {
            return num<10?num:addDigits(num/1000000000+num%1000000000/10000000+num%100000000/10000000+num%10000000/1000000+num%1000000/100000+num%100000/10000+num%10000/1000+num%1000/100+num%100/10+num%10);
        }
    };
    
    

Log in to reply
 

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