Pregunta de entrevista de H E B

Standard algorithm question, nothing to difficult.