How Dynamic Programming Solved Yhe Problem