DIY: String Compression
Explore the implementation of a string compression algorithm that modifies a character list in place to achieve constant space complexity. Learn how to compress consecutive characters by appending counts directly within the input array, and return the new length. This lesson prepares you for coding interviews by applying efficient techniques to real problems.
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.