Good day kind lady/kind sir,

Today our sample coding interview test question is gonna cover encoding. Run-length encoding to be precise. Think you’ve got the solution? Write it up in a github gist and post it in the comments below. You can use any programming language that you want.

Difficulty: Easy

Run-length encoding is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. For example, the string “AAAABBBCCDAA” would be encoded as “4A3B2C1D2A”.

Implement run-length encoding and decoding. You can assume the string to be encoded have no digits and consists solely of alphabetic characters. You can assume the string to be decoded is valid.