2243. Calculate Digit Sum of a String, Time complexity: O(N^2), Space complexity: O(N)
IntuitionApproachComplexity
Time complexity: O(N^2)

Space complexity: O(N)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(N^2)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def digitSum(self, s, k):
        len_s = len(s)
        
        while (len_s > k):
            new_s = ''
            start_index = 0
            end_pos = start_index + k
            
            while (start_index < len_s):
                substr = s[start_index:end_pos]
                sum_digits = sum([int(d) for d in list(substr)])
                new_s += str(sum_digits)
                start_index += k
                end_pos += k
            s = new_s
            len_s = len(s)
        
        return s
```
['Python3']