Yahoo Interview Question

dynamic programming question.