my python


  • 0
    H
    class Solution(object):
        def addDigits(self, num):
            """
            :type num: int
            :rtype: int
            """
            if num == 0:
                return 0
            elif num %9 == 0:
                return 9
            else:
                return num%9
    

Log in to reply
 

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