2
public String[] divideString(String s, int k, char fill) {3
// the size of result array4
String[] r = new String[(int) Math.ceil((s.length() * 1.0) / k)];6
// if the last one needs to be filled, then I do it7
if (s.length() % k != 0) {8
idx = s.length() - (s.length() % k);9
StringBuilder sb = new StringBuilder();10
sb.append(s.substring(idx));11
for (int i = sb.length(); i < k; i++) {14
r[r.length - 1] = sb.toString();16
// no need to fill the last,17
// that's why idx is equal to s length20
for (int i = 0; i < idx; i += k) {21
r[i / k] = s.substring(i, i + k);