Accumulate
C++\ncpp\nstring digitSum(string s, int k) {\n    while(s.size() > k) {\n        string s1;\n        for (int i = 0; i < s.size(); i += k)\n            s1 += to
**C++**\n```cpp\nstring digitSum(string s, int k) {\n    while(s.size() > k) {\n        string s1;\n        for (int i = 0; i < s.size(); i += k)\n            s1 += to_string(accumulate(begin(s) + i, begin(s) + min((int)s.size(), i + k), 0, \n                [](int n, char ch){ return n + ch - \'0\'; }));\n        swap(s1, s);\n    }\n    return s;\n}\n```
['C']