Dynamic Programming Solver