Python3 O(n+k) || O(n) Runtime: 52ms 41.96% || Memory: 13.0mb 70.32%
Hope I didn\'t coded this in hardcore.\n\nclass Solution:\n#     O(n+k) where n is the elements present in the string\n# and k is the number of steps\n# O(N) sp
Hope I didn\'t coded this in hardcore.\n```\nclass Solution:\n#     O(n+k) where n is the elements present in the string\n# and k is the number of steps\n# O(N) space\n# Runtime: 52ms 41.96% || Memory: 13.0mb 70.32%\n    def digitSum(self, string: str, k: int) -> str:\n        if not string:\n            return string\n        stringLength = len(string)\n        k %= stringLength \n        if stringLength == k or k == 0 or k == 1:\n            return string\n\n        return helper(string, k)\n\ndef helper(string, k):\n    newStringList = list(string)\n    newNum = 0\n    tempList = list()\n    for i in range(0, len(newStringList), k):\n        newNum = sum(map(int, newStringList[i:k+i]))\n        tempList += list(str(newNum))\n\n    result = \'\'.join(tempList)\n    if len(result) > k:\n        return helper(result, k)\n    return result\n```
['String', 'Python', 'Python3']