Simple to understand recursive Python


  • 0
    S
        split_str = list(str(num))
        values = map(int, split_str)
            
        res = 0        
    
        for i in values:
            res += i
    
        return res if len(str(res)) < 2 else self.addDigits(res)

Log in to reply
 

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