Calculate Digit Sum of a String (Finally done it on my own)
IntuitionApproachComplexity
Time complexity:
(n log n)
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:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
(n log n)
****
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(n)

# Code
```cpp []
class Solution {
public:
    string digitSum(string s, int k) {
        while(s.size()>k)
        {
            string temp="";
            int sum=0;
            for(int i=0;i<s.size();i++)
            {
                sum+=s[i]-'0';
                if((i+1)%k==0)
                {
                    temp+=to_string(sum);
                    sum=0;
                }
            }
            if(s.size()%k!=0) 
            {
            temp+=to_string(sum);
            }
            s=temp;
        }
        return s;
    }
};
```
['String', 'Simulation', 'C++']