题目如下:

【leetcode】258. Add Digits

解题思路:题目很简单,没啥说的。Follow up 我还没想出来。

代码如下:

class Solution(object):
    def addDigits(self, num):
        """
        :type num: int
        :rtype: int
        """
        while num >= 10:
            num = sum([int(x) for x in list(str(num))])
        return num

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2021-08-18
猜你喜欢
  • 2021-05-29
  • 2021-11-07
  • 2021-10-20
  • 2022-01-28
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案