Amazon Interview Question

greedy algorithm question