# 22.06.2025 [2138. Divide a String Into Groups of Size k]
# 22.06.2025
[2138. Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/description/) easy
[blog post](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/solutions/6871846/kotlin-rust-by-samoylenkodmitry-ajm8/)
[substack](https://open.substack.com/pub/dmitriisamoilenko/p/22062025-2138-divide-a-string-into?r=2bam17&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true)
[youtube](https://youtu.be/TUiVCSC3H_I)

#### Join me on Telegram
https://t.me/leetcode_daily_unstoppable/1027
#### Problem TLDR
k-chunked string, filled tail #easy
#### Intuition
Pad then chunk, or chunk then pad. Prefill everything, or write a precise filling code. Great task to learn the language built-ins.
#### Approach
* if you know Kotlin `padEnd` & `chunked` you don't have to think
* Rust doesn't allow `fmt` with dynamic fill character
* `1 + (size - 1) / k` or `(k + size - 1) / k` will pad to `% k`
* Kotln / Java `String` has `CharArray` constructor arguments
* Rust has `resize` to pad-fill a `Vec`
#### Complexity
- Time complexity:
$$O(n)$$
- Space complexity:
$$O(n)$$
#### Code
https://dmitrysamoylenko.com/2023/07/14/leetcode_daily.html
Видео # 22.06.2025 [2138. Divide a String Into Groups of Size k] канала KittyCat, Keyboard and LeetCode
[2138. Divide a String Into Groups of Size k](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/description/) easy
[blog post](https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/solutions/6871846/kotlin-rust-by-samoylenkodmitry-ajm8/)
[substack](https://open.substack.com/pub/dmitriisamoilenko/p/22062025-2138-divide-a-string-into?r=2bam17&utm_campaign=post&utm_medium=web&showWelcomeOnShare=true)
[youtube](https://youtu.be/TUiVCSC3H_I)

#### Join me on Telegram
https://t.me/leetcode_daily_unstoppable/1027
#### Problem TLDR
k-chunked string, filled tail #easy
#### Intuition
Pad then chunk, or chunk then pad. Prefill everything, or write a precise filling code. Great task to learn the language built-ins.
#### Approach
* if you know Kotlin `padEnd` & `chunked` you don't have to think
* Rust doesn't allow `fmt` with dynamic fill character
* `1 + (size - 1) / k` or `(k + size - 1) / k` will pad to `% k`
* Kotln / Java `String` has `CharArray` constructor arguments
* Rust has `resize` to pad-fill a `Vec`
#### Complexity
- Time complexity:
$$O(n)$$
- Space complexity:
$$O(n)$$
#### Code
https://dmitrysamoylenko.com/2023/07/14/leetcode_daily.html
Видео # 22.06.2025 [2138. Divide a String Into Groups of Size k] канала KittyCat, Keyboard and LeetCode
Комментарии отсутствуют
Информация о видео
22 июня 2025 г. 13:12:06
00:04:40
Другие видео канала