Galatea Associates LLC interview question

Typical algorithm problem involving strings