Pregunta de entrevista de Amazon

The second question was a string implementation problem,