Practice Divide a String Into Groups of Size k
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Read s from left to right in consecutive groups of k characters. If the final group is shorter than k, append enough copies of fill to make its length k. Do not add a group when s divides evenly. Return the groups in order, preserving every original character exactly once.
Source: Divide a String Into Groups of Size k on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "abcdefghi", k = 3, fill = "x"
Output
["abc","def","ghi"]
# Example 2
Input
s = "abcdefghij", k = 3, fill = "x"
Output
["abc","def","ghi","jxx"]
Constraints
1 <= s.length <= 100
s consists of lowercase English letters only.
1 <= k <= 100
fill is a lowercase English letter.
Related LeetCode Problems
Practice more problems similar to Divide a String Into Groups of Size k.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.