easy
\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        \n        while (true) {\n            int n(size(s));\n            int cnt(0), curr
```\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        \n        while (true) {\n            int n(size(s));\n            int cnt(0), curr(0), i(0);\n            string nn;\n            if (size(s) <= k)  break;\n            while (i < n) {\n                curr += s[i++]-\'0\';\n                if (++cnt == k or i == n) {\n                    cout << curr << "\\n";\n                    nn += to_string(curr);\n                    curr = 0;\n                    cnt = 0;\n                }\n            }\n            s = nn;\n        }\n        return s;\n    }\n};\n```
[]