Pocket Gems interview question

1 Greedy, 1 Tree question