Apple interview question

dynamic programming coding problem.