Pregunta de entrevista de Nielsen

Algorithm involving strings and how to work with it