Yahoo interview question

dynamic programming question.