Pregunta de entrevista de Amazon

solve frequently used string problem