Rippling Interview Question

Solving a string manipulation problem