Divide a String Into Groups of Size k Solution in C++
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)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n# Code\n```\nclass Solution {\npublic:\n    vector<string> divideString(string s, int k, char fill) {\n        int i, j=0;\n        vector<string> ans;\n        string temp="";\n        for(i=0 ; i<s.length() ; i++)\n        {\n            temp += s[i];\n            j++;\n            if(j==k)\n            {\n                ans.push_back(temp);\n                temp.clear();\n                j=0;\n            }\n        }\n        if(temp.length()!=0)\n        {\n            for(i=0 ; i<k-j ; i++)\n            {\n                temp += fill;\n            }\n            ans.push_back(temp);\n            temp.clear();\n        }\n        return ans;\n    }\n};\n```\n![upvote new.jpg](https://assets.leetcode.com/users/images/6b48d103-467f-4924-97ad-51d4b2ca9e8f_1685592112.2697668.jpeg)\n
['C++']