Encode Repeated Characters with Counts

Asked at Goldman Sachs · Coding Questions · Difficulty: Medium · Last asked Dec 27, 2024

You are given a list of single characters. Shorten it by writing each group of equal adjacent characters as the character followed by the size of the group, and write the result back into the same list. The caller then reads the first `k` cells, where `k` is the value you return.

Loading the problem…