Pregunta de entrevista de Mixi

A simple algorithm question was asked.