✅✅C++ || Easy Solution || 0ms || Faster
\nclass Solution {\npublic:\n    string digitSum(string s, int k) \n    {\n       return fun(s,k);    \n    }\n    string fun(string s,int &k)\n {\n \tif(s.leng
```\nclass Solution {\npublic:\n    string digitSum(string s, int k) \n    {\n       return fun(s,k);    \n    }\n    string fun(string s,int &k)\n {\n \tif(s.length()<=k)\n \t{\n \t\treturn s;\n    }\n    int idx=0;\n    string str="";\n    while(idx<s.length())\n    {\n    \tint sum=0;\n    \tint counter=0;\n    \twhile(idx<s.length() and counter<k)\n    \t{\n    \t\tsum=sum+(s[idx]-\'0\');\n    \t\tcounter++;\n    \t\tidx++;\n\t\t}\n\t\tstr=str+to_string(sum);\n\t}\n\treturn fun(str,k);\n }\n};\n```
['Recursion', 'C', 'C++']