bumpsoo 2025-06-22 12:19:52 +00:00
parent 6151b8b474
commit 8a6b22d753

View file

@ -0,0 +1,19 @@
# https://leetcode.com/problems/divide-a-string-into-groups-of-size-k
from typing import List
class Solution:
def divideString(self, s: str, k: int, fill: str) -> List[str]:
result: List[str] = []
curr: List[str] = []
for c in s:
if len(curr) >= k:
result.append(''.join(curr))
curr = []
curr.append(c)
if len(curr) > 0:
while len(curr) < k:
curr.append(fill)
result.append(''.join(curr))
return result