IBM Interview Question

dynamic programming problem