Pocket Gems Interview Question

Greedy related algorithm question