C++ Easy Solution || Beginner's Solution || Vector✅✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string digitSum(string s, int k) {\n        vector<int> ans;\n        int num=0;\n\n//Till the size of string is greater, while loop will work.\n        while(s.size()>k){\n            for(int i=0;i<s.size();i++){\n                num=0;\n                for(int j=0;j<k;j++){\n//while increasing j, always check whether i is less than the actual size.\n                    if(i<s.size()) \n                    num=num+s[i]+\'0\'-96;\n//If s[i]=1 then to change it in integer add \'0\' it become 97 thus sub 96.\n                    i++;\n                }\n            i--;\n            ans.push_back(num);\n        }\n        s.clear();   //clear previous string\n        for(int i=0;i<ans.size();i++){\n            s=s+to_string(ans[i]); \n//change each number to string for concatenation \n        }\n    \n        ans.clear();\n        }\n        return s;\n    \n    }\n};\n```
['C++']