Pregunta de entrevista de Pocket Gems

Algorithm and Design question