HTMLify
LeetCode - Sum of Digits of String After Convert - Python
Views: 379 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 | class Solution: def getLucky(self, s: str, k: int) -> int: n = "" for c in s: n += str(ord(c)-96) for _ in range(k): s = 0 for n_ in n: s += int(n_) n = str(s) return int(n) |