Pregunta de entrevista de Goldman Sachs

Implement a run length encoding function. For a string input the function returns output encoded as follows: "a" -> "a1" "aa" -> "a2" "aabbb" -> "a2b3" "aabbbaa" -> "a2b3a2" "" -> ""