1 line C++


  • 0
    class Solution {
    public:
        int addDigits(int num) {
            return num%9 ? num%9 : num ? 9 : 0; 
        }
    };
    

Log in to reply
 

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