Free written solution

Divide a String Into Groups of Size k (LeetCode 2138): Solution and Explanation

Split a string into consecutive chunks of length k, padding the final chunk with a fill character when it comes up short.

Read the intuition, approach, code and complexity →