Search⌘ K
AI Features

DIY: String Compression

Understand how to implement an efficient string compression algorithm that modifies the input list in place using constant space. Learn to handle consecutive character groups by appending counts, and return the compressed string length, key for coding interviews.

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:

  1. If the group’s length is 1, you will append the character to s.
...