Saturday, December 2, 2017

258. Add Digits

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

No comments:

Post a Comment