Berbix interview question

Coding challenge involving string manipulation