python leetcode 258. 各位相加
2018-03-30 19:34
363 查看
人生苦短,我用python
我感觉我这种做法太邪恶了。。。class Solution:
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
num=str(num)#变成字符串来进行处理
count=0
while len(num)!=1:
for i in num:
count += int(i)
num=str(count)
count=0
return int(num)
我感觉我这种做法太邪恶了。。。class Solution:
def addDigits(self, num):
"""
:type num: int
:rtype: int
"""
num=str(num)#变成字符串来进行处理
count=0
while len(num)!=1:
for i in num:
count += int(i)
num=str(count)
count=0
return int(num)
相关文章推荐
- (LeetCode)Add Digits --- 整数各位相加
- LeetCode 258. Add Digits(数位相加)
- [LeetCode-258] Add Digits(非负整数各位相加)
- LeetCode:Add Digits - 非负整数各位相加
- [LeetCode] 2. Add Two Numbers 两数相加 @python
- [LeetCode]258. Add Digits(把数各个位上的数字相加)
- [LeetCode258] Add Digits 非负整数各位相加
- leetcode258-Add Digits(非负整数各位相加)
- 2.两数相加-Python-LeetCode
- LintCode python 小白-简单题-569各位相加
- LeetCode:Add Digits - 非负整数各位相加
- 【LeetCode with Python】 Maximum Subarray
- [Leetcode] Add Two Numbers Python实现 详细讲解
- leetcode-Count Primes 以及python的小特性
- [LeetCode]题解(python):144-Binary Tree Preorder Traversal
- leetcode hIndex implemented with python
- [LeetCode]题解(python):085-Maximal Rectangle
- LeetCode 50 — Pow(x, n)(C++ Java Python)
- leetcode-python 第七周
- leetcode 99 Recover Binary Search Tree (python)