[C++] String problem
\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        while(s.length()>k){\n            string temp="";\n            int p=0, sum=0;\n   
```\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        while(s.length()>k){\n            string temp="";\n            int p=0, sum=0;\n            for(int i=0; i<s.length(); i++){\n                sum += s[i]-\'0\';\n                p++;\n                if(p==k){\n                    temp += to_string(sum);\n                    sum=0;\n                    p=0;\n                }\n            }\n            if(p>0) temp += to_string(sum);\n            s=temp;\n        }\n        return s;\n    }\n};\n```
['String', 'C']