A string s can be partitioned into groups of size k using the following procedure:


	The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each character can be a part of exactly one group.
	For the last group, if the string does not have k characters remaining, a character fill is used to complete the group.


Note that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.

Given the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.

&nbsp;
Example 1:

Input: s = "abcdefghi", k = 3, fill = "x"
Output: ["abc","def","ghi"]
Explanation:
The first 3 characters "abc" form the first group.
The next 3 characters "def" form the second group.
The last 3 characters "ghi" form the third group.
Since all groups can be completely filled by characters from the string, we do not need to use fill.
Thus, the groups formed are "abc", "def", and "ghi".


Example 2:

Input: s = "abcdefghij", k = 3, fill = "x"
Output: ["abc","def","ghi","jxx"]
Explanation:
Similar to the previous example, we are forming the first three groups "abc", "def", and "ghi".
For the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice.
Thus, the 4 groups formed are "abc", "def", "ghi", and "jxx".


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 100
	s consists of lowercase English letters only.
	1 &lt;= k &lt;= 100
	fill is a lowercase English letter.


class Solution:
    def divideString(self, s: str, k: int, fill: str) -> List[str]:
        l, i, N = [], 0, len(s)
        while i<N:
            l.append(s[i:i+k])
            i += k
        last = l[-1]
        if(len(last)<k):
            l[-1] += fill*(k-len(last))
        return l
class Solution {
    public String[] divideString(String s, int k, char fill) {
        int rem = 0;
        if( s.length() % k != 0){
             rem = k - s.length() % k; //counting the total positions where we have to fill the char "fill".
        }
        for(int i = 0; i < rem; i++){
            s = s+fill; //appending the char to the String
        }
        
        String[] strs = new String[s.length()/k];  //the length will be String length / K because we are making pair of k length Strings.
        int index = 0;  //index for array.
        for(int i = 0; i < s.length(); i+=k){
            strs[index] = s.substring(i, i+k); //substing of  current element to Kth element. 
            index++;
        }
        return strs;
    }
}
class Solution {
public:
    vector<string> divideString(string s, int k, char fill) {
        vector<string> v;
        for(int i=0;i<s.size();i=i+k)
        {
            string t=s.substr(i,k); // make substring of size atmost k

            if(t.size()==k) // if size if k then push
            {
                v.push_back(t);
                continue;
            }

            int l=t.size(); // if it is the last group and size if less than k
            for(int j=0;j<(k-l);j++) // add fill char to t to make size k
                t+=fill;

            v.push_back(t);
        }
        return v;
    }
};
/**
 * @param {string} s
 * @param {number} k
 * @param {character} fill
 * @return {string[]}
 */
var divideString = function(s, k, fill) 
{
  var ans=[];
  for(let i=0;i<s.length;i+=k)
    {
      ans.push(s.substring(i,i+k));
    }
  let str=ans[ans.length-1];
  if(str.length==k)
    {
      return ans;
    }
  for(let i=str.length;i<k;i++)
    {
      ans[ans.length-1]+=fill;
    }
  return ans;
};
Divide a String Into Groups of Size k