class Solution(object):
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
if num == 0:
return 0
return num - (num-1) / 9 * 9
Runtime: 72 ms
class Solution(object):
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
if num == 0:
return 0
return num - (num-1) / 9 * 9
Runtime: 72 ms