Pythonic One-Liner


  • 0
    F

    Nothing much to talk about though. FYI.

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

Log in to reply
 

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