runlengthencodingrun - bradendubois/competitive-programming GitHub Wiki

Run-Length Encoding, Run!

ID: runlengthencodingrun

Difficulty: 1.9

CPU Time: 1 second

Memory: 1024 MB

Solution

For decoding) check every second character, starting at the first character (the one to output), and loop the amount of times of the number immediately following, outputting this character. For encoding, one can loop through the string and simply count the occurrences of each character, and output the character and tally as one goes.