python/java easy to understand
\tclass Solution:\n\t\tdef divideString(self, s: str, k: int, fill: str) -> List[str]:\n\t\t\tcur = ""\n\t\t\tres = []\n\t\t\tfor c in s:\n\t\t\t\tcur += c\n\t\
\tclass Solution:\n\t\tdef divideString(self, s: str, k: int, fill: str) -> List[str]:\n\t\t\tcur = ""\n\t\t\tres = []\n\t\t\tfor c in s:\n\t\t\t\tcur += c\n\t\t\t\tif len(cur) == k:\n\t\t\t\t\tres.append(cur)\n\t\t\t\t\tcur = ""\n\t\t\tif cur != "":\n\t\t\t\tcur += fill * (k - len(cur))\n\t\t\t\tres.append(cur)\n\t\t\treturn res\n\n\n\tclass Solution {\n\t\tpublic String[] divideString(String s, int k, char fill) {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tList<String> res = new ArrayList<>();\n\t\t\tfor (char c: s.toCharArray()) {\n\t\t\t\tsb.append(c);\n\t\t\t\tif (sb.length() == k) {\n\t\t\t\t\tres.add(sb.toString());\n\t\t\t\t\tsb = new StringBuilder();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (sb.length() != 0) {\n\t\t\t\tint n = k - sb.length();\n\t\t\t\tfor (int i = 0; i < n; i ++) {\n\t\t\t\t\tsb.append(fill);\n\t\t\t\t}\n\t\t\t\tres.add(sb.toString());\n\t\t\t}\n\t\t\treturn res.toArray(new String[res.size()]);\n\t\t}\n\t}
[]