Goldman Sachs interview question

Given a string, e.g., 'aaabbc', give a result like 3a2b1c.