Domanda di colloquio di IBM

I was asked a question on text algorithm