Pregunta de entrevista de Pocket Gems

Greedy related algorithm question