Rippling interview question

Solving a string manipulation problem