Expedia Group interview question

Leetcode: change strings such as "aaaabb" to "a4b2"