Pocket Gems interview question

1st round phone: Greedy problem