Amazon Interview Question

Greedy algorithm.