2138. Divide a String Into Groups of Size k
2022. 1. 22. 10:22ㆍAlgorithm/Leetcode, Lintcode, HackerRank, etc.
- 목차
반응형
class Solution:
def divideString(self, s: str, k: int, fill: str) -> List[str]:
n = len(s)
res = []
i = 0
while i < n:
pad = k - len(s[i:i + k])
res += s[i:i + k] + fill*pad,
i += k
return res
반응형
'Algorithm > Leetcode, Lintcode, HackerRank, etc.' 카테고리의 다른 글
2244. Minimum Rounds to Complete All Tasks (0) | 2022.05.01 |
---|---|
2243. Calculate Digit Sum of a String (0) | 2022.04.29 |
2248. Intersection of Multiple Arrays (0) | 2022.04.29 |
2134. Minimum Swaps to Group All 1's Together II (0) | 2022.01.09 |
2133. Check if Every Row and Column Contains All Numbers (0) | 2022.01.09 |