2243. Calculate Digit Sum of a String
2022. 4. 29. 19:50ㆍAlgorithm/Leetcode, Lintcode, HackerRank, etc.
- 목차
반응형
class Solution:
def digitSum(self, s: str, k: int) -> str:
while len(s) > k:
i = 0
next = ''
while i < len(s):
next += str(sum([int(ch) for ch in s[i:min(i + k, len(s))]]))
i += k
s = next
return s
반응형
'Algorithm > Leetcode, Lintcode, HackerRank, etc.' 카테고리의 다른 글
2409. Count Days Spent Together (0) | 2023.01.07 |
---|---|
2244. Minimum Rounds to Complete All Tasks (0) | 2022.05.01 |
2248. Intersection of Multiple Arrays (0) | 2022.04.29 |
2138. Divide a String Into Groups of Size k (0) | 2022.01.22 |
2134. Minimum Swaps to Group All 1's Together II (0) | 2022.01.09 |