Wayfair Interview Question

Compact words aabbcc -> a2b2c2 aabaabb -> 2ab2a2b