Skip to content

Commit eb40f9f

Browse files
committed
Jun 22
1 parent daf8dfb commit eb40f9f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def divideString(self, s: str, k: int, fill: str) -> list[str]:
3+
s += fill * (-len(s) % k)
4+
return [s[i: i + k] for i in range(0, len(s), k)]
5+
6+
7+
def main():
8+
s = 'abcdefghi'
9+
k = 3
10+
fill = 'x'
11+
assert Solution().divideString(s, k, fill) == ['abc', 'def', 'ghi']
12+
13+
s = 'abcdefghij'
14+
k = 3
15+
fill = 'x'
16+
assert Solution().divideString(s, k, fill) == ['abc', 'def', 'ghi', 'jxx']
17+
18+
19+
if __name__ == '__main__':
20+
main()

2025-06-June-LeetCoding-Challenge/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
| June 19 | [2294. Partition Array Such That Maximum Difference Is K](https://leetcode.com/problems/partition-array-such-that-maximum-difference-is-k/) | Medium | Solved |
2626
| June 20 | []() | | |
2727
| June 21 | [3085. Minimum Deletions to Make String K-Special](https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/) | Medium | Solved |
28-
| June 22 | []() | | |
28+
| June 22 | [2138. Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/) | Easy | Solved |
2929
| June 23 | []() | | |
3030
| June 24 | []() | | |
3131
| June 25 | []() | | |

0 commit comments

Comments
 (0)