Apple Interview Question

dynamic programming coding problem.