Leetcode 2138: Divide a String Into Groups of Size k

Example:
s = "abcdef", k = 4, fill = 'x'
Return: ["abcd", "efxx"]
  • First, we want all the substrings of size k by using the function substring in a loop. In the loop we will keep track of an index currIndex starting at 0 and incremented of k after each iteration.
  • The loop stops when…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store