2138. Divide a String Into Groups of Size k
A string
scan be partitioned into groups of sizekusing the following procedure:
- The first group consists of the first
kcharacters of the string, the second group consists of the nextkcharacters of the string, and so on. Each element can be a part of exactly one group.- For the last group, if the string does not have
kcharacters remaining, a characterfillis used to complete the group.Note that the partition is done so that after removing the
fillcharacter from the last group (if it exists) and concatenating all the groups in order, the resultant string should bes.Given the string
s, the size of each groupkand the characterfill, return a string array denoting the composition of every groupshas been divided into, using the above procedure.
1 | class Solution { |