Amazon interview question

Greedy algorithm.