Compress a string by encoding runs of consecutive identical characters with their counts.
Unlock detailed company stats for this questionUpgrade
To reduce the size of messages transmitted over the internet, a compression algorithm encodes consecutive repeating characters in a string. Scan the string from left to right and group consecutive identical characters. If a character appears once, add just the character to the output. If it appears more than once in a row, add the character followed by the number of consecutive occurrences. Example: input aaaaabbbccca, output a2b3a2b2c3a as written by the poster.
Community answers
No answers contributed by the community yet.
Related questions
Repeatedly remove k consecutive identical characters from a string until it is stable.Given a binary string, split it into even length substrings of identical characters with the minimum number of flips.Count binary string arrangements with no consecutive ones.Related courses

Course

Course
Course
