Pocket Gems interview question

2nd round phone: Reverse Backpack problem