Tulip interview question

String processing brain-teaser