How to Solve Dynamic Programming Problems