Pocket Gems interview question

two dynamic programing questions