Python recursion with 32ms (beat 99% so far)


  • 0
    L

    I think in this case, it's way faster to reduce the number using the method the question describes

        def addDigits(self, num):
            """
            :type num: int
            :rtype: int
            """
            if num // 10 == 0:
                return num
            return self.addDigits(num // 10 + num % 10)
    

Log in to reply
 

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