DIY: String Compression
Explore how to compress a list of characters by grouping consecutive duplicates and encoding their counts in-place. Understand the algorithm’s constant space requirements and implement the StringCompression function to return the compressed length. This lesson helps you develop skills essential for solving space-efficient string manipulation problems in coding interviews.
We'll cover the following...
We'll cover the following...
Problem statement
You are given a list of characters. Your task will be to compress this list, using the following algorithm:
For each group of consecutive repeating characters in the string:
- If the group’s length is
1, you will append the character tos.