Pocket Gems Interview Question

1st round phone: Greedy problem