Python solution 52ms


  • 1
    H
    class Solution:
        # @param {integer} num
        # @return {integer}
        def addDigits(self, num):
            if not num:
                return 0
            if not num%9:
                return 9
            return num%9

Log in to reply
 

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