C++ | 0ms Solution | Recursion with comments
\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        // if length is smaller or equal to k, no more rounds left\n        if (s.length() 
```\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        // if length is smaller or equal to k, no more rounds left\n        if (s.length() <= k)\n            return s;\n        \n        // find string after this round\n        string round_str;\n        for (int i=0; i<s.length(); i+=k) {\n            int sum = 0;\n            // process the next group of size <= k by summing individual digits\n            for (int j=i; j<i+k && j<s.length(); j++){\n                sum += s[j]-\'0\';\n            }\n            \n            // append sum to final sring\n            round_str += to_string(sum);\n        }\n        \n        // recursion to proceed to next round\n        return digitSum(round_str, k);\n    }\n};\n```
[]